So... why would I want this to be user-customizable... they'd want as close to real-time as possible, yeah?
But what they don't want, at any cost, is for the page to refresh before it's fully-loaded, which would render the script unusable. The exact point at which the script is loaded will be different for each person; someone on 33k is going to have a DRASTICALLY different loading time to someone on 10MB/s broadband, even with such a small page.
Code:
<body onLoad="javascript:sndReq();">
should be:
Code:
<body onLoad="sndReq();">
... and I recommend you use setInterval rather than setTimeout to avoid "too much recursion" errors:
Code:
function sndReq() {
http.open('GET', 'messages.php');
http.onreadystatechange = handleResponse;
http.send(null);
setTimeout("sndReq()", 2000);
}
window.setInterval("sndReq()", 2000);
Bookmarks