fiddle : http://fiddle.jshell.net/xvwz2bt4/
Using the ajax code below (pure js) :
var xhr;
xhr = new XMLHttpRequest();
function xhrDocOpen(doc,placeID){
xhr.onreadystatechange=function(){
if(xhr.readyState==4 && xhr.status==200){
document.getElementById(placeID).innerHTML=xhr.responseText;
}
}
xhr.open('GET',doc,true);
xhr.send();
}
xhrDocOpen('a.txt','apple');
xhrDocOpen('b.txt','banana');
Initially, I believed this code to be correct.
However, upon further testing, it became apparent that it was not functioning as intended.
In the 'xhrDocOpen' function above, the first one doesn't display a.txt... While the second one displays b.txt correctly.
The reason behind this issue is currently unknown...
Can anyone identify the problem?