libsfan01 wrote:
Thanks for the help Laurent
I was also wondering about the effect on server-load, is this a
resource intensive process? For example is it much more efficient than
a constantly refreshing iframe?
>Simply call the getdata() function in processdata()
function processdata() {
if (get.readyState == 4) {
data = get.responseText;
document.getElementById("display").value = data;
getdata();
}
}
Note: You should plan error handling. For example, what do you do if the
status is not 200?
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Laurent's suggestion is a good one, but realize that as soon as you get
data back from the server the web page is going to go right back and ask
for another update. This can be quite stressful on your web server if
you don't need a continuous stream of live data.
Another approach would be instead of doing getdata() in your process
function, you setup a timeout instead....
setTimeout('getdata()',5000);
This will call getdata() but it will let 5 seconds (5,000 milliseconds)
elapse before it does it. 5,000 can be whatever you want just put in
(number of seconds * 1000).
-----------------------
There's no difference, server impact wise, between automatically
refreshing ajax calls and automatically refreshing iframes.
Hope that helps you out a bit.
--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA