By default, ajax use sync request which is done in parallel. Unfortunately, ajax request still waiting for the task in server to complete (this is done by php) if only php session been used. To overcome this, you can use session_write_close() so that other requests can be made simultaneously.
Before using the session_write_close(), please make sure that any session write is not used because the session write will not work. The flow is something like this:
- Use ajax request
- In php, use any necessary session write before heavy task like large database request, download, etc.
- Use session_write_close() so that any other request from ajax can run without waiting for the heavy task in php(server) to complete.
- After the heavy task is done, can use the session_start() to enable the session write if required.