i have a loop that calls an ajax function that checks to see if a file exists. it looks like this...

Code:
/* some functions up here */
var exists = 0;
while (exists != 1) {
   ajaxfunction("restoreExists", "/file/path/");
   if (output) { exists = 1; }
}
/* some functions down here */
however, the above code simply locks up my browser. by the time this function is called, the file should be available within seconds.

BUT - when i add in an alert() showing me the status of "exists" it works fine, just with an annoying alert() box.

Code:
/* some functions up here */
var exists = 0;
while (exists != 1) {
   ajaxfunction("restoreExists", "/file/path/");
   if (output) { exists = 1; }
   alert(exists);
}
/* some functions down here */
any ideas on what i can do without having to call on an alert()?