Reputation: 43788
Anyone know what's going wrong with below code? The system will only call the getProgressMsg()
after the Ajax is completed :(
function ajax_action(action)
{
setTimeout('getProgressMsg()',2000);
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="admin.php"
url=url+"?action=admin"
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function getProgressMsg()
{
xmlHttp2=GetXmlHttpObject2();
if (xmlHttp2==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url2="admin.php"
url2=url2+"?action=getMsg"
url2=url2+"&sid="+Math.random()
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url2,true);
xmlHttp2.send(null);
}
Upvotes: 0
Views: 257
Reputation: 159708
stateChanged()
, then getProgressMsg()
won't be called until you return.getProgressMsg()
beyond making another AJAX request - are you sure that's not just being queued up by the browser or the web server to where it won't finish processing 'till the first one completes?getProgressMsg()
with a simple call to alert()
. Then reduce the delay from 2000 to 200, and see if it doesn't show up immediately.stateChanged()
.Upvotes: 1