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.
(3) You could actually check to see if the operation completed normally.
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);
displayStatus('Waiting'); // this line could actually be first in this function or before send...makes no difference