Two AJAX asynchronus GET call: Only one get the xml file
- by Woho87
Hi!
I have two AJAX GET calls that are set to asynchcronus = true;
I want to obtain two XML files on my server. The two AJAX calls and rendering are defined in function foo & koo. And are called simultaneously.
function foo(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
var xmlDoc = xmlhttp.responseXML;
//Do something
}
}
xmlhttp.open('get', 'url', true);
xmlhttp.send();
}
function koo(){
//Almost the same as function foo
}
foo();
koo();
I've noticed that inside the if statement in the first function call(foo), the code their will never compile. While in the second function call(koo). The code inside the if statement can be compiled. If I set both asynchronus to false, then there is no problem at all. If I remove the second function call(koo) from the code, than the code inside the if statement can be compiled.
What can I do to have both asynchronus AJAX calls?