I need to wait for a specific set of evnets to happen before I do something (it's multiple xmlhttprequests and I need them all to be finished and some processing to take place).
Here's how I do it:
while (this.resources.find( function(v,i) { return v.state < 2 } )) { alert("test"); }
(.find is prototype.js thing that finds an element in some collection according to the function result, I tried to replace it with common for loop and the problem persists).
With alert(as shown here) everything works - I click ok, by that time all requests are loaded and the code continues; without alert, however, firefox hangs and (I suppose) the code that handles xmlhttp request completion never fires, state is never set (it's a custom field I defined) so the browser is dead.
Is there any way to set a delat in javascript? I know of settimeout but its application here would be really ugly...
Here's how I do it:
while (this.resources.find( function(v,i) { return v.state < 2 } )) { alert("test"); }
(.find is prototype.js thing that finds an element in some collection according to the function result, I tried to replace it with common for loop and the problem persists).
With alert(as shown here) everything works - I click ok, by that time all requests are loaded and the code continues; without alert, however, firefox hangs and (I suppose) the code that handles xmlhttp request completion never fires, state is never set (it's a custom field I defined) so the browser is dead.
Is there any way to set a delat in javascript? I know of settimeout but its application here would be really ugly...