
Originally Posted by
Yahoo! Answers (just "JR")
You have three "machines":
- The buyer's machine, the one that places the order and send it to the server.
- The server, who receives the order, and updates the database.
- The Shop monitor, who "looks" at the database.
Remember one thing: a server NEVER send anything to anyone by itself: the server only RESPONDs to a request.
So, the Shop monitor asks the page, receives it, then... do nothing.
The database can be updated 1000 times, the monitor will NOT be informed, UNLESS it makes a request.
To do this (and it is the technique of most chat boards), you set-up a small timer in the Shop monitor page, sending a request every, say, 5 seconds, to the server. (for a chat, every 2-5 sec is ok, for orders, maybe 20, 60 secs? - to be adjusted).
On the request, the server checks if the order list has "changed" (more records or something else). It the order list has not changed, the server sends a reply "nothing new" (sort of), otherwise, it sends a reply to update a part of the screen (AJAX).
You could have a part of the screen as a scrollable box, or an iframe. The server sends the order list from the last first, refreshing the list every x secs. The rest of the screen does not change.
Very scarce on ressources!
Bookmarks