by admin
2. February 2010 09:23
JavaScript has a function, setInterval(code, timeout) that can be used to periodically update a visitors web browser. Using this feature you could simulate pushing updates from the server side to the clients browser using AJAX.
The setInterval(<code>, <timeout>) function call takes 2 parameters. <code> which is the javascript call to run and <timeout> is the interval at which to periodically make that call. The call specified as the <code> parameter can be an AJAX call to fetch the data and update the browser part.
function pageLoad(sender, args) {
setInterval('UpdatePage();', 2000);
}
For example, the above javascript function can be set to run on page load, which in turn will call the UpdatePage() Javascript call every 20 seconds.
for a complete example, take a look at the 4 guys site @ http://aspnet.4guysfromrolla.com/articles/012109-1.aspx