Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
267 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...