Say we have a webpage, and user(s) add data, just plain text. Gets written to db.
What is the best method, for polling the server in realtime and updating a div..
So like a ul li list constantly gets updated, posting new data at top of list and shuffling everything down a line.
I have seen scripts like this, just wondered what is best practice and if anyone has any demo or links. This isnt something we want someone to do for us, its a little project I am working on.
Need the data to poll once a second, or so. I suppose using json.
I am using a similar method for a chat system. I am sending the chat in a json array.
Updating just a single li item as you suggested is probably better as it will use less data.
The best way though is this: http://cometd.org
Facebook use a similar method for their chat system. Basically instead of polling every 1 second a session is left open on the server. There isn’t a great deal of documentation or easy to use classes though (for PHP that is). So the first method is easier.
Thanks for that link, it looks very useful.
I was amazed with that too, socket.io and html5 storage persistence etc seems the way to go, I just really want to accomplish a very simple task. I dont want to reivent the wheel, but by the same token … Persistent client side -> server connections annoy the crap out of me. So hence I was looking for a server push method.
Kind of : if newData connect to user , echo newData content. Nothing earth shattering.
I may have to look at node.js again