Y
Y
yurygolikov2016-07-27 19:22:23
PHP
yurygolikov, 2016-07-27 19:22:23

How to interrupt the processing of an interrupted AJAX request on the server (php)?

Apache server, bang on.
I'm new, please don't throw stones.

How to interrupt the processing of an AJAX request on the server that was interrupted by the client.
On the client side, I interrupt like this:
ajax_request.abort();
On the server, I tried to interrupt in this way, but nothing comes out , because I don’t really understand the ins and outs of the process.

//Первый метод (не работает)
ignore_user_abort(false);
//Второй метод (не работает)
if(connection_aborted()){
  exit;
}

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Evgrafovich, 2016-07-28
@yurygolikov

No way. abort cancels waiting for a response from the server, this does not affect the server itself in any way. It's like if you sent a letter and while it's coming, you decide to move to another apartment. The letter will still be read by the addressee.

L
l0vefist, 2016-07-28
@l0vefist

The server will realize that the connection is broken only when it tries to send something to the client.
More details: www.php.su/phphttp/?connhandling

A
Anton F, 2016-08-04
@fregate

Watching, of course, what request and how much is executed.
For example, a pool of tasks is created on the server and a PoolWorker thread takes tasks from there and executes them in turn.
Something sent a task from the site, which was placed in the pool. Then something cancels this task.
We receive a cancellation request, check the pool, if there is, we delete the task, if not, then we look in the already running tasks (threads), if there is, we close the thread.
It is clear that this is all asynchronous, sometimes the task will have time to be executed. How to do it synchronously is not very clear.

P
Pavel Belousov, 2016-08-04
@PafNutY

Send another ajax request to abort the operation.
But here the question arises, which operation should be interrupted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question