开发者

jquery refresh timer kills previous values

开发者 https://www.devze.com 2023-02-28 21:41 出处:网络
I have a comment script similar to facebook, I adde开发者_开发技巧d in a jquery timer to refresh the contents on div id, it does what it is suppose to do, but the problem is it kills the values of the

I have a comment script similar to facebook, I adde开发者_开发技巧d in a jquery timer to refresh the contents on div id, it does what it is suppose to do, but the problem is it kills the values of the other script I use in the same file on refresh, is their some way of fixing this or is it a dead duck so to speak. many thanks if I can get this to work with some help.

<script>
$(document).ready(function() {
    $("#responsecontainer").load("index.php");
    var refreshId = setInterval(function() {
        $("#responsecontainer").load('index.php?randval='+ Math.random());
    }, 60000);
    $.ajaxSetup({ cache: false });
});
</script>

<div id="responsecontainer">


Check out my answer to the following question. I would suggest using IIFE over setInterval(). I also think its a bit cleaner.

Refresh a table with jQuery/Ajax every 5 seconds

0

精彩评论

暂无评论...
验证码 换一张
取 消