There are already some examples ... depending on the server side, you can go java-hello-world or php-hello-world or ...
if you cannot use websocket , you have to go the old way, create the window.setInterval interval and pull the data from the server, for example. $.ajax() . I don't know any other alternative to bi-directional connection (websocket) ... see kayahrs answer
as you asked for this:
$.ajax() is a jQuery way to do xhr . basically, it runs an asynchronous request to the server, which returns xml or json or text or ... (independently). when this request returns, a supported eventHandler is triggered, and you can respond to the response. you can also use plain xhr, but this is a bit inconvenient for handling the original xhr.
jQuery supports some shorthand overloads for $.ajax() , for example. $.getJSON() , $.get() , ...
implementation example:
$.get("test.cgi", function(data){ alert("Data Loaded: " + data); });
source share