> I have several functions with code along the lines of:
> var xmlDoc = requestXML("ajax.asp?SP=SelectRelatedTags&tag=" +
> array[i]);
> The requestXML() function includes the code:
> var xmlDoc = null;
> http_request.onreadystatechange = function() {
> if (http_request.readyState == 4) {
> if (http_request.status == 200) {
> xmlDoc = http_request.responseXML;
> } else {
> alert('There was a problem with the request.' +
> http_request.status);
> }
> }
> };
> http_request.open('GET', url, true);
> http_request.send(null);
> return xmlDoc;
> However, the last line (the return) executes before the readyState
> reaches 4. How do I return the xmlDoc to the functions only once the
> xmlDoc has been assigned? I tried putting the return statement in a
> while loop with the condition that the readyState must = 4 - this
> worked, but makes the browser popup a message saying the script is
> slowing down the system.
> Thanks,
> Iain