Answer the question
In order to leave comments, you need to log in
How to stop php script execution using js?
I load the page, and after loading I pull up the data from the database using xmlhttprequest. It happens that you have to wait more than a minute for a response from the server, and you can’t leave this page by clicking on the navigation element. Is there any way to stop php script execution with js?
The request is asynchronous. All events on elements work.
.abort() kills the request, but until the server responds, you can't leave the page.
I believe that it is necessary to somehow break the connection with the server in order to stop the execution of the script, but I don’t know how to do this.
Answer the question
In order to leave comments, you need to log in
You most likely have a classic problem with sessions. The AJAX script, although asynchronous, occupies a handle to work with the session file. And until he finishes it (the end of the script, or through a function), the file will not be released and the user will not be able to make any other request. There are several solutions:
1. Transfer work with sessions to the database/memcached/redis
2. Close the session after reading it and write changes at the end of the script (if any).
at the same time, it is impossible to leave this page by clicking on the navigation element.
... I pull up the data from a DB by means of xmlhttprequest. It happens that you have to wait more than a minute for a response from the server, ..If I were you, in this situation, I would first of all deal with the work of the database, which gives data for more than a minute. This is number one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question