search

Home  >  Q&A  >  body text

javascript - thinkphp+ajax problem

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

为情所困为情所困2865 days ago626

reply all(8)I'll reply

  • 仅有的幸福

    仅有的幸福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.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:04:34

    Just open an interface and read the database information

    reply
    0
  • 迷茫

    迷茫2017-05-16 13:04:34

    Try socket and notify the client when the server is updated

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 13:04:34

    Ajax words. Just polling. Make a scheduled js to do ajax and post the code later

    reply
    0
  • 滿天的星座

    滿天的星座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!

    reply
    0
  • 迷茫

    迷茫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

    reply
    0
  • PHPz

    PHPz2017-05-16 13:04:34

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

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 13:04:34

    Ajax polling, use timer settimeout()

    reply
    0
  • Cancelreply