If you would change to an ASYNCHRONOUS call, you'd solve THREE problems at once.
(1) Your "Waiting.." would display as soon as
send() is called.
(2) You would not be freezing JavaScript while waiting for the send to complete.
(3) You could actually check to see if the operation completed normally.
Code:
function doDownload(pageId)
{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function ()
{
if (xmlhttp.readyState==4 )
{
displayStatus ( ( xmlhttp.status==200) ? "Ready" : "Error " + xmlhttp.status );
}
}
xhttp.open("GET", "http://127.0.0.1:7101/testApp/images?pageId=" + pageId, true);
xhttp.send();
displayStatus('Waiting'); // this line could actually be first in this function or before send...makes no difference
}