I have a problem with this ajaxRequest() function I have. I have a form that the submit button calls 2 seperate div's to load new content via the ajaxRequest:
PHP Code:
<input type="button" value="Add Data" onClick="ajaxRequest('div1', 'inbox.php'); ajaxRequest('div2', 'outbox.php');">
The problem is when you click on the button, it loads the second ajax function in the onClick event handler and the first seems to get jammed up waiting for a response.
here's my function:
Code:
function ajaxRequest(divTag,url)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//loading animation
document.getElementById([divTag]).innerHTML="<image src=../images/loading.gif></img>";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById([divTag]).innerHTML=xmlhttp.responseText;
parent.calcHeight();
}
}
xmlhttp.open("GET",[url],true);
xmlhttp.send();
}
Bookmarks