my task is to do a long running JS code. This routine generate a POST request, and when its over and need to, generates another according to the answer:\[code\]function routine (a){ var answer = createPostRequest (bla bla bla); if (answer) { routine (a); }}\[/code\]so it recursively calls itself as long as the answer is true. So far its good, but then browser freezes, or hangs too much. After a time, Firefox will tell me that script is running too long, and offers to stop it.Instead of doing \[code\]routine (a);\[/code\] I tried to do with a \[code\]setTimeout\[/code\] with timing 1. The same things, but when I set 100 for timing, it looks ok. But there are unnecessarry waitings, plus its a subjective number (what if even that 100 causes problems?)I need some kind of "message based" thing, like in Delphi/Windows programming: a program sends a message to itself. How can it be achived in JS?Edit: the way I generating the request:\[code\]var ajax = createXmlHttp();ajax.open ('POST', 'dsdsdsad.adsf', false);var parameters = 'param=1';ajax.setRequestHeader ('Content-type', 'application/x-www-form-urlencoded');ajax.setRequestHeader ("Content-length", parameters.length);ajax.setRequestHeader ("Connection", "close");ajax.send (parameters);try{ var answer = eval('(' + ajax.responseText + ')');}catch (error){ alert ('Error in the answer: '+ajax.responseText); return;}\[/code\]