[Javascript] window.setTimeout() not timing out?

Barry Beattie BarryB at alphabus.com.au
Tue Jan 18 17:03:10 CST 2005


hi all.

I'm using the xmlhttprequest object to get JS to run a remote procedure.
The problem is not really about xmlhttprequest, more about why
setTimeout isn't firing.

(background info)
using xmlhttprequest object works great  - except if there's a network
"hic-up" and the reply from the RPC is slow to return. 

I'm trying to do this up by
1) using the xmlhttprequest object in syncronus (async = false) mode
2) specifying a time when it should time out 
3) aborting it and warning the user

I can delay the return from remote procedure easily (using Java's
sleep() on the thread).

(the problem)
but when I do, the setTimeout method doesn't trigger - it just delays
the execution of the js (that is, the "recieved" and "all ok" alerts
still fire, just delayed by how long I made the reply "sleep")

any idea why window.setTimeout() isn't firing?

(code snip)
alert("setting timeout now...");
g_TimeoutID = window.setTimeout("page_RemoteHttpDataTimeout()", 10);
alert("sending...");
oXMLHTTP.Send(null); //this should time out here
alert("recieved");
if (oXMLHTTP != null 
		&& oXMLHTTP.readyState == 4 
		&& oXMLHTTP.status == 200) {
	alert("all OK");
	window.clearTimeout(g_TimeoutID);
...

(note: "page_RemoteHttpDataTimeout()" just has an alert in it)




More information about the Javascript mailing list