For example, if I have num in the database = 1, I display 1 on the page, but now I have set num in the database = 2, so how can I update 2 on that web page without refreshing it? Please give me an example, the ajax method
仅有的幸福2017-05-16 13:04:34
It depends on how much you use. If it is a very simple project and only a few people use it, then just use polling.
If it is a business with high requirements or large usage, you need to use swoole on the back end to implement long socket links. I remember there is a WebSocket object on the front end that can be used to call your socket interface.
By the way, swoole can only be used under Linux, and swoole cannot be installed on Windows servers.
滿天的星座2017-05-16 13:04:34
Ajax words. Just polling. Make a scheduled js to do ajax and post the code later
滿天的星座2017-05-16 13:04:34
You'd better describe the specific scenario and then choose how to implement this function, because if you keep using ajax to poll, it will be a waste of server resources!
迷茫2017-05-16 13:04:34
If real-time performance is not required (for example, it is not chatting), then ajax long polling is fine.
If you need high real-time performance, then Workerman or Swoole is suitable for you
PHPz2017-05-16 13:04:34
Many ways, workman, swoole, socket.io+node.js, trigger reverse proxy refresh, etc.