I'm doing an asynchronous request to load a json file using XMLHttpRequest(). I would need to wait for the request completion before going on with the rest.
I saw the ajaxComplete() should do just this, but I can't apply it to my actual code and get it working.
Here I'm setting up the function that calls the json via asynchronous request
function ajaxCall(){
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
arrayImages = JSON.parse(xmlhttp.responseText);
output(arrayImages);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
Here I'm calling that function
ajaxCall();
Now I want that it is completed
do other things
Any help ?
Thanks!