通过 AJAX 调用的 PHP 进程是否在“ESC”上取消?
如果我进行 AJAX 调用,如果用户按“ESC”或离开该页面,AJAX 调用是否会被取消?
如果 AJAX 调用被取消,我的 PHP 脚本是否会继续运行,直到完成正在执行的操作(假设没有达到时间限制或任何其他服务器配置停止。),或者该进程会同时被终止吗?它属于哪个 Apache 孩子?
如果该进程确实被 Apache 子进程杀死,即使它没有完成,那么保持其活动状态的最佳方法是什么,或者我应该考虑哪些其他选项? (ZendX_Console_Process_Unix 不是一个选项)。
谢谢!
后来的发现:
如果我在 Firefox 中按“ESC”(在 firebug 中检查),AJAX 调用实际上会被取消。 PHP 进程将继续,并且不受按 ESC 或关闭选项卡的影响。
If I do an AJAX call, would the AJAX call be canceled if the user pressed "ESC" or leaved that page?
If the AJAX call gets canceled, would my PHP script continue to run until it finished what it was doing (provided time limit doesn't get reached or any other server configuration stops.), or would that process get killed at the same time as the Apache child it belongs to?
If the process does get killed with the Apache child even if it didn't finish, what would be the best way to keep that alive be or what other options should I consider? (ZendX_Console_Process_Unix not an option).
Thanks!
Later discoveries:
The AJAX call actually gets canceled if I hit "ESC" in Firefox (checked in firebug). The PHP process continues and is not affected by hitting ESC or closing the tab.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果服务器进程在用户结束 ajax 调用(关闭窗口或移动到另一个网站)之前启动,那么它将一直执行到最终结果。
但是中断的ajax调用(意味着数据的传输没有完成)服务器将不会处理该调用。
注意:点击 ESC 本身不会结束 ajax 调用,除非您用 JavaScript 编写了该按键行为。
If the server process starts before the user ends the ajax call (closing the window, or moving to another website) then it will be carried out until its final result.
But an interrupted ajax call (meaning the transmission of data was not completed) the server will not process the call.
Note: hitting ESC will not end an ajax call per se, unless you javascripted that keypush behaviour.
需要注意的是...如果您使用 href 属性从超链接调用 AJAX 调用,那么是的,用户可以按 ESC 并停止传输。
One note... if you invoked your AJAX call from a hyperlink, using the href attribute, then YES, the user can press ESC and stop the transmission.