在ajax更新期间离开网页
Leaving a webpage during an ajax update
当用户向服务器发送异步请求以更新其数据库时,可能需要几分钟,但在更新完成之前就离开了网页,会发生什么?
服务器将继续记录更新到数据库还是停止?
我正在使用angularjs来异步调用LAMP堆栈
假设:
- 服务器收到请求
- 服务器可以无错误地处理
- 请求处理程序中有一个数据库更新逻辑
则no,服务器将不将更新记录到数据库中。
正如@AD7six指出的,根据这个php手册参考:
原因:
The default behaviour is however for your script to be aborted when the remote client disconnects.
If you do not tell PHP to ignore a user abort and the user aborts, your script will terminate.
选项:
You can decide whether or not you want a client disconnect to cause your script to be aborted. Sometimes it is handy to always have your scripts run to completion even if there is no remote browser receiving the output.
如何:
This behaviour can be set via the ignore_user_abort php.ini directive as well as through the corresponding php_value ignore_user_abort Apache httpd.conf directive or with the ignore_user_abort() function.
也有一个TIMEOUT
中止:
原因:
Your script can also be terminated by the built-in script timer. The default timeout is 30 seconds.
If you do not tell PHP to ignore a user abort and the user aborts, your script will terminate.
选项:
It can be changed using the max_execution_time php.ini directive or the corresponding php_value max_execution_time Apache httpd.conf directive as well as with the set_time_limit() function.
这是基本的客户机-服务器通信流:
客户端(网页、浏览器等)向服务器和发送请求 (sync/async)服务器向客户端发送响应。
服务器可以像客户端一样处理连接超时和中止。
- 如何防止网页加载后自动启动功能
- 离开页面时弹出消息
- 如何使用Node.js最有效地解析网页
- 如果用户选择离开网页,如何删除记录
- 使用SoundJS离开网页会导致Google Chrome崩溃
- 如何在用户离开网页时显示模态窗口
- 当用户离开网页时添加到 Apache 日志文件
- 如何融合网页之间的过渡,给人一种访问者从未离开过页面的错觉
- 另一个“;如何在不离开网页的情况下改变URL”;
- 如何暂停视频时,焦点离开我的网页(html5)
- 检测用户是否“离开”网页上
- 在离开未保存更改的网页之前警告用户
- 在ajax更新期间离开网页
- 设置cookie在用户离开网页时过期
- 如何确定用户何时离开网页(不包括某些链接)
- 阻止用户离开网页,除非提交表单
- 如何使网页在用户离开时过期
- 创建一个弹出窗口,并在用户尝试离开我的网页时获取结果
- 如果用户试图离开网页,如何提示他们未保存的更改
- 当用户刷新或离开网页时调用ajax函数