•  0
    Ajax

    Make complete parallel request using ajax and php session function

      Asmin Jismun    276        0        Report content

    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:

    1. Use ajax request
    2. In php, use any necessary session write before heavy task like large database request, download, etc.
    3. Use session_write_close() so that any other request from ajax can run without waiting for the heavy task in php(server) to complete.
    4. After the heavy task is done, can use the session_start() to enable the session write if required.

     


  •  


Leave a Comment

Please Login to insert comment.

 

Facebook Conversations