Home  >  Q&A  >  body text

java - 如何将从客户端获取的实时信息显示到页面上?

PHP中文网PHP中文网2741 days ago372

reply all(4)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:07:14

    Your idea is not quite right. You don’t need to make the connection yourself, but continue to use the browser’s connection method, such as http(s) ws protocol.
    The browser has no way to handle other communication protocols other than these categories.

    So there are currently several methods of implementation.

    1. Long polling, the page sends a request every few seconds or tens of seconds to ask the backend if there is new data, and it will be loaded if there is. The implementation method is useful for ajax or iframe.

    2. Websocket requires the browser to support html5 and initiate a truly long connection. The server can send information to the client at any time.

    reply
    0
  • PHPz

    PHPz2017-04-18 10:07:14

    The front end can use WebStocket

    reply
    0
  • PHPz

    PHPz2017-04-18 10:07:14

    ajax rotation training can do it

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 10:07:14

    The backend receives, the frontend uses AJAX to request data, and then renders the page.

    reply
    0
  • Cancelreply