java - 如何将从客户端获取的实时信息显示到页面上?
PHP中文网
PHP中文网 2017-04-18 10:05:14
0
4
369
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
伊谢尔伦

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.

PHPzhong

The front end can use WebStocket

PHPzhong

ajax rotation training can do it

小葫芦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!