AJAX异常中断不中止在服务器上,仅在客户 [英] ajax abort is not aborting on the server, only for the client

查看:176
本文介绍了AJAX异常中断不中止在服务器上,仅在客户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,我用

var x=ajax.....

if(x){x.abort();}

不过这并不会导致在我的PHP文件,该文件的方式,尽管该选项为默认设置为ignore_user_abort堕胎(假)

but this does not cause an abortion inside my php file, which by the way although the option is by default it is set to ignore_user_abort(false)

这意味着如果连接是丢失那么脚本将不会继续执行。

meaning that if connection were to be lost then the script would not continue execution.

问题是,它似乎也将继续执行,code虽然对JS的客户端AJAX中止。

The problem is it appears it keeps on executing code although ajax on js client side aborted.

如何通过JS实现两者的流产成功,客户端和服务器端的PHP停止。

How to accomplish via js the successful abortion of both, client side and server side php stopping.

推荐答案

如果您需要确认的东西被放弃,你必须发送另一个请求要问,如果你的工作完成与否。这意味着,你以后叫 xhr.abort()你必须发送一个请求,像 /中止/ JOBID 以找出是否有人能够完成处理之前中止。

If you need to confirm that something was aborted you have to send another request to ask if your job finished or not. That means that after you call xhr.abort() you have to send a request to something like /abort/jobId to find out whether it was able to abort before finishing processing.

没有什么神奇的方法来保证PHP脚本会后立即停止中止()电话。

There's no magic way to guarantee that the PHP script will stop immediately after the abort() call.

这篇关于AJAX异常中断不中止在服务器上,仅在客户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆