My site uses lots of AJAX requests to PHP files which then retrieves
data from MySQL. About 95% of the time the requests complete without
issues. Every once in a while a request will hang for exactly 5
minutes then fail. It seems to be occuring on the client side. I
can't re-create the issue. It just happens randomly. I think it
eventally reaches the server (Apache) because I can see errors in the
server log that certain POST/GET variables are undefined. The
variables are clearly defined. One thing it could be is that it's
only tied to POST requests since I read somewhere that POST makes two
requests to the server. I have this issue with IE6 and IE7 and could
be tied to the wininet.dll I briefly read about as well. I'm not
sure. Below is the typical structure I use for my requests. Any help
will be appreciated. Thanks...
function loginReq(frm){
var req=false;
var msg=document.ge tElementById("m sg");
msg.innerHTML=" ";
msg.className=" error";
if(window.XMLHt tpRequest){
req=new XMLHttpRequest( );
}else if(window.Activ eXObject){
try{req=new ActiveXObject(" Msxml2.XMLHTTP" );}catch(e){
try{req=new ActiveXObject(" Microsoft.XMLHT TP");}catch(e){ }}
}
if(!req){
msg.innerHTML=" There was a problem with the request!";
return false;
}
req.onreadystat echange=functio n(){
if(req.readySta te==4){
if(req.status== 200){
if(req.response Text.substr(0,1 )=='<'){
document.getEle mentById("main" ).innerHTML=req .responseText;
}else{
msg.innerHTML=r eq.responseText ;
}
}else{
msg.innerHTML=" There was a problem with the request!";
}
}
}
var prm='user='+frm .user.value+'&p asswd='+frm.pas swd.value;
req.open('POST' ,'login.php',tr ue);
req.setRequestH eader("Content-type","applicat ion/x-www-form-
urlencoded");
req.setRequestH eader("Content-length",prm.len gth);
req.setRequestH eader("Connecti on","close");
req.send(prm);
}