I have a simple async function to load php content to a div, but I must be missing something cos when I action the function twice in a row, there's a mess.
Here's my js:
function loadbox(url,targetbox){
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp=new XMLHttpRequest();
}else{// code for IE6, IE5
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById(targetbox).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.send();
};
And when I trigger the loadbox() with onclick, it doesn't load the content to one of the divs.
onclick="loadbox('first.php','firstdiv');loadbox('second.php','seconddiv');"
I can only guess I'm messing upthe asynchronous loading of the content, cos when I set the attribute to false in the .open(), it works ok. But then it's not what I'm looking for.