I’m creating a website element where users can contribute to a discussion. In doing so, the latest contributions need to appear at the top of the list at a regular short interval, using Ajax.
While I know how to return the initial results, I’m not sure how to go about adding only the latest updates to the current list of items.
Help, anyone?
thanks,
Geoff
One way is, make an ajax call to a server page which returns the contents in a reguar interval and show that in the content div.
A simple example which makes a call to a page called getlatestposts.php in every five seconds and show to the div with id comments, is below. This will start executing on document ready (after the dom is loaded)
If you don’t want to do this approach of making so much of calls to server in every 2 seconds or so , you should seriusly look into something like SignalR which does asynchronous push to the calle.