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.
Suggestions ?
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.
Hey Michael, thanks.
Great reply. I have been looking at http://www.ape-project.org/ , but to be honest is a bit beyond my scope. Will check out your examples in depth tho 
Funnily enough this is for and part of an aussie project I have in mind.
Thanks for that link, it looks very useful.
I think it is crazy that people are using JavaScript for the server side though! But if it works I spose it’s cool.
michaeldale said
Thanks for that link, it looks very useful. I think it is crazy that people are using JavaScript for the server side though! But if it works I spose it’s cool.
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
