Answer the question
In order to leave comments, you need to log in
Why doesn't the php script exit after the user leaves?
Good afternoon.
Explain, who can, one moment.
There is a site, the user enters the page loading the main elements of the site, then when the DOM is formed, ajax requests data from the server (the php script is long, there is a lot of data, all the data goes in one response) and puts them in the right blocks. The problem is that if the user clicks on a link to go to another page without waiting for all the data to load, the site freezes. And already when ajax received a response and inserted the values, only then the user will be redirected where he clicked.
Is the php script execution not interrupted when the user navigates away from the page?
How can this problem be solved?
Answer the question
In order to leave comments, you need to log in
Maybe someone will come in handy.
The problem was solved by itself, the site was transferred to the hosting. Apparently there were problems in the php.ini configuration, namely "output_buffering".
The same problem happens due to blocking sessions if the script does work with them. In this case, I did not work with sessions.
Is the php script execution not interrupted when the user navigates away from the page?Why would he stop? In fact, these are 2 absolutely unrelated actions - going to the page and executing the script. More precisely, the first initializes the second, and after that it does not affect what is happening on the server in any way.
It is logical that the AJAX function during its operation blocks the transition to any links. Until the AJAX function unblocks the transitions (having received data), there will be no transitions. Look not in PHP, but in AJAX functions in the browser.
You seem to be opening a session in both scripts and not closing it.
As a result, the second waits for the first to release this session, hanging on the call to open the session (for the browser, it looks like the server has hung, because it received the request, but has not yet sent anything in response).
If you don't need to write anything else to the session, close it as soon as possible. https://www.php.net/manual/ru/function.session-write...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question