javascript - thinkphp+ajax problem
为情所困
为情所困 2017-05-16 13:02:34
0
8
618

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

为情所困
为情所困

reply all(8)
仅有的幸福

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 updated

滿天的星座

Ajax 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

PHPzhong

Many ways, workman, swoole, socket.io+node.js, trigger reverse proxy refresh, etc.

刘奇

Ajax polling, use timer settimeout()

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template