M
mouac01
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.getElementById("msg");
msg.innerHTML="";
msg.className="error";
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
try{req=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){
try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}
}
if(!req){
msg.innerHTML="There was a problem with the request!";
return false;
}
req.onreadystatechange=function(){
if(req.readyState==4){
if(req.status==200){
if(req.responseText.substr(0,1)=='<'){
document.getElementById("main").innerHTML=req.responseText;
}else{
msg.innerHTML=req.responseText;
}
}else{
msg.innerHTML="There was a problem with the request!";
}
}
}
var prm='user='+frm.user.value+'&passwd='+frm.passwd.value;
req.open('POST','login.php',true);
req.setRequestHeader("Content-type","application/x-www-form-
urlencoded");
req.setRequestHeader("Content-length",prm.length);
req.setRequestHeader("Connection","close");
req.send(prm);
}
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.getElementById("msg");
msg.innerHTML="";
msg.className="error";
if(window.XMLHttpRequest){
req=new XMLHttpRequest();
}else if(window.ActiveXObject){
try{req=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){
try{req=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}
}
if(!req){
msg.innerHTML="There was a problem with the request!";
return false;
}
req.onreadystatechange=function(){
if(req.readyState==4){
if(req.status==200){
if(req.responseText.substr(0,1)=='<'){
document.getElementById("main").innerHTML=req.responseText;
}else{
msg.innerHTML=req.responseText;
}
}else{
msg.innerHTML="There was a problem with the request!";
}
}
}
var prm='user='+frm.user.value+'&passwd='+frm.passwd.value;
req.open('POST','login.php',true);
req.setRequestHeader("Content-type","application/x-www-form-
urlencoded");
req.setRequestHeader("Content-length",prm.length);
req.setRequestHeader("Connection","close");
req.send(prm);
}