AJAX: How to notify when there is new data?

JTEwv

New member
Basically, I have requests for an Internet radio station loaded into a DJ site via AJAX - every 10 seconds, it checks for requests. If there's nothing new, obviously the <div> doesn't change, but if there is, then the <div> changes with the new data. How can I make the title bar flash (similar to that of new IMs in Gmail or Meebo) or something to notify the DJ that there's new content on that webpage (but only when there IS new content?)

Thanks!
 
I would probably use 2 AJAX calls. One to ask...Anything New? It would probably need to pass 1 param, a timestamp or something else meaningful to the server..basically 'New Since When?'.

Only if it returns true would you then make the second call to load the div, and do something to notify the DJ.

A couple advantages: You don't have to format and send the div content every 10 seconds. So less bandwidth.
Assuming the answer is coming out of a database, all you need is a super fast query, probably a select count(*) to know if there is anything new. You don't need to bring the whole result set back from the DB every 10 seconds.
 
Back
Top