开发者

jQuery/Ajax - Live update

I have a cron job running searching Twitter every 5 minutes, each 5 minutes the results of the search are written to a database.

开发者_Python百科

Im surfacing the twitter search results in a simple HTML list.

What I would like to do is load any new search results at the top of this list every 5 minutes.

Can any suggest how I might go about doing this?


You should look at the jQuery Timers Plugin

Here's a tutorial with demo page to get you started


I would write a function to update the HTML list, then use setInterval to run it:

function updateList(){ /*magic*/ }

setInterval(updateList,1000*5*60); //Run updateList every 5 minutes

MSDN documentation

Mozilla documentation


Why not simple use a window.setInterval() with a 5 minute interval to call the AJAX function every 5 minutes to get the new results?

Or you can also do it without any JavaScript. Just insert the HTML into an iframe and use the refresh meta in this iframe:

<meta http-equiv="refresh" content="3000; URL=http://www.example.com/twitterlist">


Use the since_id paramter - http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜