One ajax call block other ajax call

后端 未结 1 1771
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 22:43

Once my page is loaded, I perform an Ajax call to a php script, which updates my server. However this script can sometimes take over a minute to complete, and while the scri

1条回答
  •  不要未来只要你来
    2021-01-13 23:21

    adeno's comment above is correct.

    "in PHP only one script at a time can operate on the same session, so as to not overwrite session data etc. So when doing two ajax calls to PHP scripts within the same session, the second has to wait for the first to finish"

    to help speed things up you can write to and end a session early(session_write_close()) to release the session-lock and allow another script using the session to continue.

    note: you can still read from your $_SESSION variable after calling session_write_close but you may no longer write to it.

    you can find a good example of this here: PHP Session Locks – How to Prevent Blocking Requests

    example provided from the link above:

    
    

    0 讨论(0)
提交回复
热议问题