Problem with IE and setInterval() not refreshing/updating

I'm using JavaScript/Jquery to make a page auto-update with a value from a database, although it doesn't seem to update in Internet Explorer. It works fine in FireFox & Chrome. Can anyone explain what's wrong? It looks like IE is just displaying a cached version of the page. How can I prevent this happening? Thanks.

function updateComm() {  
 var url="commandSys.php";  
 jQuery("#theElement").load(url);  
}

setInterval("updateComm()", 1000);

Answers


Try disabling the cache with ajaxSetup

$.ajaxSetup ({
    // Disable caching of AJAX responses */
    cache: false
});

function updateComm() {  
 var url="commandSys.php";  
 jQuery("#theElement").load(url);  
}

setInterval(updateComm, 1000);

Alternatively, you can manually just append a +new Date to url so it appends a query string to prevent caching.

Alternatively, disable caching on the server-side.


Your php page is cached. Has nothing to do with the interval. Set the right caching headers on the page.


Need Your Help

why jquery's ui.css files's font-sizes are bigger than normal?

jquery user-interface font-size

Im looking at jqueries tabs, datepicker etc and see that font-sizes of the classes added to elements are like 1.1em, 1em which seems big in the page. Why did they do this like that?

Check whether a string matches a regex in JS

javascript regex match

I want to use JavaScript (can be with jQuery) to do some client-side validation to check whether a string matches the regex: