I wrote a JavaScript method to load content into my page with an interval of one second. It works fine in Chrome and Firefox, but not in Internet Explorer. Automatic reboot after 1000 ms does not work.
How to fix it?
function testing() {
$.getJSON('test.php', function(data) {
var lastresult = data.lastresult;
$('#test').html(lastresult);
});
}
window.setInterval(function(){testing()}, 1000);
EDIT (I found a solution): IE cached the result test.php, so it doesn't seem to work for me. Adding this to the script worked:
jQuery.ajaxSetup({ cache: false });
Also, I tried the code below and they worked for me.
Example 1 (worked):
function testing() {
$.getJSON('test.php', function(data) {
var lastresult = data.lastresult;
$('#test').html(lastresult);
});
}
testing();
Example 2 (worked):
function testing() {
alert('test');
}
window.setInterval(function(){testing()}, 1000);
source
share