I must admit, this is my first post on this site, so I apologise in advice if I do something wrong (formatting etc).
Anyway, I'm creating a kind of mmo using javascript (and jQuery), and so far everything is running fine in Chrome, Safari, Firefox, etc. However, I've found that somewhere along the line, Internet Explorer crashes.
By reproducing the crash I've narrowed it down to this code:
function getUpdates(){
var data={uid:playerName,area:1,mid:lastMessage};
$.ajax({
url: "getUpdates.py",
timeout: 32000,
data: data,
type:"GET",
complete: function(obj, textStatus){
//handleUpdates(obj);
getUpdates();
}
});
}
Which is supposed to poll for updates over a long time. However, in IE after one reply this code gets stuck in an infinite loop, which will crash the browser. It doesn't seem to crash after every reply, only if there is no server response.
Note, the line that says "complete:..." has been tried as:
success: function(...){getUpdates();...},
error: function(...){getUpdates();...}
with the same problem occurring.
IE is returning the AJAX call instantly from a cache.
You should add a random parameter to the URL to force IE to ignore its cache, like this:
url: "getUpdates.py?RandomNumber=" + Math.random(),
(You can also use new Date
)
Also, you should probably check for updates a little more slowly by adding a 5 second delay:
complete: function(obj, textStatus){
//handleUpdates(obj);
setTimeout(function() { getUpdates(); }, 5000); //milliseconds
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With