Server Side Reload Initiation on Ajax Call

前端 未结 3 1541
南方客
南方客 2020-12-07 05:19

I need to initiate a reload from the server side(PHP) durring and AJAX call. How do I do this. I honestly don\'t think it is supported.

My current method is to u

3条回答
  •  失恋的感觉
    2020-12-07 05:58

    There is a pattern that uses AJAX to create a PUSH-alike application. I don't know the real name of the paradigm, nor a good implementation, but this is basically how it works:

    1. Client makes AJAX request to server.
    2. Server doesn't close the connection.
    3. When server wants to push. server says:
      a. Process push message X
      b. Initiate a new connection. (i.e. goto 1.)
      < Server closes connection >

    So there is always a "hanging" connection, and as soon as the server wants to respond, the client immediately creates a new one that hangs again.

提交回复
热议问题