Problem with IE and setInterval() not refreshing/updating

前端 未结 2 590
庸人自扰
庸人自扰 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.

提交回复
热议问题