tags:

views:

40

answers:

4

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

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?

+1  A: 

You should look at the jQuery Timers Plugin

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

irishbuzz
A: 

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"&gt;
Kau-Boy
Beware, meta refresh is deprecated
irishbuzz
A: 

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

fire
+1  A: 

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

Kristoffer S Hansen
Also I would set the first call to `updateList` based on when the last cron job was run - so if it was ran 30 seconds ago when the page was first called set the first call to be in `300 - 30` seconds.You will then want another `setInterval` call to be at the bottom of `updateList`:- `function updateList() { /* magic */ setInterval('updateList()', 1000*5*60); }`
Kevin Sedgley
I'm guessing if the first 30 seconds were critical, you wouldn't update it every 5 minutes.
Kristoffer S Hansen