Problem with IE and setInterval() not refreshing/updating

前端 未结 2 589
庸人自扰
庸人自扰 2020-12-09 04:10

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 &

相关标签:
2条回答
  • 2020-12-09 04:36

    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.

    0 讨论(0)
  • 2020-12-09 04:38

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

    0 讨论(0)
提交回复
热议问题