取消ajax调用后,如何取消PHP进程? [英] How to cancel a PHP process, when ajax call is cancelled?

查看:89
本文介绍了取消ajax调用后,如何取消PHP进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发具有大型数据库的CRM系统.如果用户要搜索客户,则可以使用ajax搜索.每次他在搜索字段中更改某项内容时,在呼叫挂起时,旧呼叫都会被取消,而新呼叫将被发送到服务器.我的问题是,服务器端的php进程继续运行.因此,如果用户开始输入地址,则会启动和取消多个请求,并且服务器需要越来越多的时间来回答.

i am currently working on a CRM system with a huge database. If the user wants to search a customer, he can use the ajax search. Everytime he changes something in the search field, while a call is pending, the old call is cancelled and a new one will be send to the server. My problem is, that the php processes on server side continue running. So if the user starts typing in an address, several requests are started and cancelled and the server needs more and more time to answer.

取消ajax调用后,是否可以取消正在运行的php进程?或者在服务器端是否有可能的解决方案,以检测来自同一用户的搜索请求是否正在运行并在启动新请求之前将其取消?

Is is possible to cancel the running php process, when the ajax call is cancelled? Or is there a possible solution on server side, to detect if a search request from the same user is running and cancel it before starting the new one?

预先感谢您的回答.

推荐答案

您在寻找ignore_user_abort()吗?

Are you looking for ignore_user_abort() ?

http://www.php.net/manual/zh/function.ignore-user-abort.php

这篇关于取消ajax调用后,如何取消PHP进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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