with this function
<script type="text/javascript">
function ajaxcall(div, page)
{
if (window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();}
else
{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(div).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",page,true);
xmlhttp.send();
}
</script>
i use my ajax. But in the page i call 2 times this function:
<script type="text/javascript">ajaxcall("menu", "perfil.php");</script>
<script type="text/javascript">ajaxcall('mapadiv', "map2.php");</script>
But happens that only one of them works, if i remove one the other works. What im doing wrong? Thanks!
Its likely that ajaxcall is throwing an error and causing the execution to stop.
Run it through a debugger and find out whats going wrong (Firebird, Chrome Developer Tools etc).
try declaring "var xmlhttp" when the function execution begins.
first time when you call the function ajaxcall the xmlhttp object is created and by the time you send the request, you are calling the same function and the object is over written. That's the reason only one request is working.inorder to avoid this you may want to store the objects in an array and then process it.