javascript - ajax queries still waiting after window close -


i have webpage has ajax call gets data php script.

ajaxrequest = new xmlhttprequest(); ajaxrequest.open("get", "submit.php?id=" + id, true); ajaxrequest.send(null); 

inside submit.php wait binary finish , create outfile.

while(1){     if(is_file($outfilepath)){         break;     }else{         sleep(60);     } } 

the problem if user closes browser window, ajax call , corresponding httpd not aborted.

and if user refreshes webpage multiple times, end having hundreds of httpd processes waiting the same outfile created.

apache server status 115 requests being processed, 5 idle workers  wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww_w____........ ................................................................ ................................................................  scoreboard key: "_" waiting connection, "s" starting up, "r" reading request, "w" sending reply, "k" keepalive (read), "d" dns lookup, 

i believe answer needed send data client (which closed), , causes php realize connection has been closed, have exit script.

while(1){     if(is_file($outfilepath)){         break;     }else{         sleep(60);         print " ";         ob_flush();         flush();         if(connection_aborted() != 0{             exit;         }     } } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -