开发者

Ajax refresh of div not pulling in new forum posts

开发者 https://www.devze.com 2023-03-20 15:22 出处:网络
I\'m using开发者_开发技巧 Simple:Press in Wordpress, and I have an Ajax auto-refresh code in the header, which refreshes ONLY the div that has the newest thread posts.

I'm using开发者_开发技巧 Simple:Press in Wordpress, and I have an Ajax auto-refresh code in the header, which refreshes ONLY the div that has the newest thread posts. The page refreshes just fine, but won't load in any new posts in that thread.

Here's the code in my header:

    <script>
    var refreshId = setInterval(function()
    {
        $('.sfposttable').fadeOut("fast").load('response.php').fadeIn("fast");
    }, 60000);
    </script>

Any ideas why the div refreshes, but doesn't pull in any new posts?


I think you have to use first

$(document).ready(function() {
    var refreshId = setInterval(function()
    {
        $('.sfposttable').fadeOut("fast").load('response.php').fadeIn("fast");
    }, 60000);

});

Here is a working example: http://jsfiddle.net/943UA/

Also you may want to change the refresh time: 60000 -> 1 minute make it 2000 -> 2 sec for test purpose.

0

精彩评论

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