tags:

views:

148

answers:

4

I'm not sure how to phrase it the best way, but what I'm looking for is a way to display data on a web page as it becomes available. Examples: Displaying IRC channel messages on a web page, as a message is sent to an IRC channel, the message is outputted to the web page at the same time (or with very little delay). Or when data is inserted into database, it is outputted to a web page at the same time (again, or with very little delay). How is such a feature implemented? Can such a feature be implemented with JS/JQuery? I'm assuming yes since that's how Mibbit seems to work (AJAX). An example or pseudo-code explanation would be appreciated since I have absolutely no idea where to even start and what I need.

+1  A: 

That sort of problem has always two types of solution: poll or push.

You can poll using AJAX techniques OR have a long-lived connection to a server pushing data to the client (COMET).

jldupont
+1 for the AJAX, as that would have been my suggestion.
Jason Whitehorn
+1  A: 

The term is Comet, and it's basically just a block of code setup to run forever and poll ( send an HTTP request ) at intervals to get new data back, if any and populates an existing area with the new data.

You can read more about it:

A tutorial ( not the best style of code ):

Stackoverflow question with an example:

meder
A: 

If you are planning to use javascript, then you will probably have a timer class that every so often it will fetch an update using ajax.

Samuel
+2  A: 

This is precisely what you are looking for. Both concept and actual code + current applications are given :

Get started on HTTP Streaming >>>

Shankar Ramachandran