All of the code in the fetchId function after the call makePrototypeAjaxCall executes immediately, before the Ajax request has a chance to finish. The alert seems to fix things because the delay caused by the alert allows the request to complete.
You can't do anything that relies upon the completion of the request before the request completes. That's what the onComplete callback is for.
The fix is to move anything that needs to wait until the request is complete into the onComplete handler or to code that is called from that handler.
Your problem was created when you put code that needs to wait until the request finishes in the function that kicked off the request. Any such code needs to be moved. [ November 02, 2007: Message edited by: Bear Bibeault ]