AJAX 调用中止后服务器无响应
我遇到过这样的情况:我对服务器的 Ajax 调用可能需要很长时间(30-40 秒)。我正在使用 jQuery.ajax 并将超时设置为 60 秒。因此,如果我在 60 秒内没有收到任何响应,调用将中止并报告错误。
现在的问题是,在此之后对服务器的任何连续调用都会一直等待,而不仅仅是 AJAX 调用,甚至在新窗口中从同一服务器打开一个新页面,也会一直等待。让它再次工作的唯一方法是完全重新启动浏览器。可能是什么原因造成的?这和服务器有关系吗?
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 same 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您中止 ajax 请求时,PHP 脚本实际上会继续运行。
如果您使用会话,则用户的会话将被正在运行的脚本锁定,并且您必须等待脚本终止才能执行其他请求。
这与php图像期间服务器工作负载增加完全相同的问题 解决方案
是在做很长的事情之前解锁会话:
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: