JQuery & PHP - can I push from the server?

后端 未结 5 1272
野趣味
野趣味 2021-02-20 11:18

I am just starting to look at JQuery; until now everything has been PHP.

Just curious: if the server detects an event and wants to update the user\'s browser, can I do s

5条回答
  •  别那么骄傲
    2021-02-20 11:57

    The HTTP protocol works on the request-response principle which means that the server can only generate a response following a request from the client. This means that the server cannot send a response to the client without having received a request in the first place. This is not a PHP issue, it is an HTTP issue. So no, you can't push, the client has to make a request, or poll. You could take a look at long polling, as alex suggested.

提交回复
热议问题