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
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.
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!
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
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.
Just open an interface and read the database information
Try
socket
and notify the client when the server is updatedAjax words. Just polling. Make a scheduled js to do ajax and post the code later
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!
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
Many ways, workman, swoole, socket.io+node.js, trigger reverse proxy refresh, etc.
Ajax polling, use timer settimeout()