V
V
Victor Diditsky2016-01-13 19:51:26
PHP
Victor Diditsky, 2016-01-13 19:51:26

Why when switching to another page, it does not load until the ajax requests on the current page are completed?

Good evening!

The essence of the problem is as follows:
If you are on a page (for example, on the main one), on which long ajax requests (15-20 seconds) are executed, try to go to another page, then it will not be loaded until the ajax requests are completed. Even if you try to open the page in another tab, it will not be loaded immediately.

It is not clear to me why this happens and how to get around this limitation.
Established empirically that during the execution of these requests. pages from another browser open.

Questions I wanted answered or directions to dig.
1. Why does the browser wait until ajax requests are completed and only after they are completed does it process others? After all, it is possible to make several connections to the server at the same time.
2. Perhaps there are some php, apache settings to bypass these restrictions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Artemyev, 2016-01-14
@GhostSt92

It's not the browser waiting for a response, it's the server not responding.
The script you access with AJAX blocks the session until it completes its work.
Here is the solution to your problem.
konrness.com/php5/how-to-prevent-blocking-php-requests
epsiloncool.ru/programmirovanie/php/zavisanie-skri...

E
entermix, 2016-01-13
@entermix

Perhaps requests are executed in synchronous mode?

Asynchronous request:
A request whose response is being processed at any time during the execution of a script or application is called asynchronous. is inherently a separate data stream that does not affect or delay other procedures.
Synchronous request:
Well, everything is clear here, a synchronous request is the opposite in meaning to an asynchronous one.

www.rsa-team.ru/forum?theme=sinhronnie_i_asinhronn...

6
65536, 2016-01-14
@65536

lock sessions. if there is a session_start in the script, then it opens the session file, and until it closes, another instance of this script or another script will not be able to open it, so requests are queued. welcome to do-it-yourself session organization. I don't recommend messing with session_set_save_handler. the most normal option is to give the browser a cookie with a key and use it to store separate independent parts of the session data in the database, so that they do not collapse during asynchrony, this is already your joy. standard sessions just protect from this with their stupidity

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question