Let's go through the problem step, your solution to the problem (abort ajax on the client side) is not the solution indeed, the problem is on the server side.
How do I stop PHP from executing?
PHP by default stops the request every time the user drops the page. The only coding for this does not occur if you set a
ignore_user_abort(true) or if you set the value in
ignore_user_abort = 1 in
If the remote client disconnects, the ABORTED state flag is turned on. A remote client disconnect is usually caused by the user hitting his STOP button.
The problem is that when using
mysqli_* , for example , but it should also be applicable to you, this happens outside of PHP. Basically PHP no longer has control over this directly. But after returning to the PHP command the process will be killed, understand that when you enter
$array_de_retorno the process will be killed because the user aborted.
But, if I make another request, does it wait for the previous request?
This is probably the use of
ISOLAMENTO (and also the
LOCKING of tables) of the database used. The first situation is extremely more likely in your case (and in most cases). There is also the possibility of defining some rate limit , which defines how many requests can be made per client, this can be defined in Apache / Nginx (and related).
But, let's most likely, when you do this:
It will block writing and writing to the session, which is a mere file , this will cause any other request to be blocked.
One solution is to use
session_write_close() and thus allow another request read and write the data in the session file, because when you call the
session_write_close() indicates that the process will no longer write anything, but you can still read
See this answer about this same problem.