Server unresponsive after AJAX call is aborted
I have a situation where my Ajax call to the server may take a long time (30-40 seconds). I am using jQuery.ajax and setting the timeout to 60 seconds. So, if I do not get any response in 60 seconds, the call is aborted and an error is reported.
The problem now is any successive calls to the server after this point just keeps waiting, not just AJAX calls, even opening up a new page from the s开发者_如何学Pythoname server in a new window, just keeps waiting. The only way to get it working again is to restart the browser completely. What might be causing this? Is this something to do with the server?
When you abort the ajax request, the PHP script actually continues to run.
If you use sessions, the user's session is locked by the running script, and you have to wait for the script to terminate before being able to do an other request.
This is the exact same problem as in Server workload increase during php image resize
The solutions is to unlock the session before doing very long things:
session_write_close();
do_something_long();
session_start();
精彩评论