For a dynamic page, I use Ajax Long Polling and even with jQuery 1.9, Internet Explorer hangs after the first request.
The script code is based on the article Simple Long Polling Example with JavaScript and jQuery
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
(function poll(){
$.ajax({ url: "ajaxstats.json", success: function(data){
$("button.requests" ).empty().append(data.requests);
}, dataType: "json", complete: poll, timeout: 30000 });
})();
});
</script>
The console shows no errors.
The IE network monitor immediately shows many requests to the ajaxstats.json
resource with a response time of < 1 ms and a 304 (not modified)
response code. The response body is correct (JSON code).
The server code always delays the answer by 1000 milliseconds. And in Firefox, Firebug XHR log shows that every request takes around 1000 milliseconds, as expected.
The HTTP response code is different between Firefox and Internet Explorer:
200 ok
304 (not modified)
Is there a way to work around this IE problem?
Try setting cache param to false, if set to false, it will force requested pages not to be cached by the browser.
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
(function poll(){
$.ajax({ url: "ajaxstats.json", success: function(data){
$("button.requests" ).empty().append(data.requests);
}, dataType: "json", complete: poll, timeout: 30000, cache: false });
})();
});
</script>
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