For example, the data in my database is 5 and then the page is 5. Now I change the data in the database to 10. I want the page to be updated to 10 but there is no need to update the page. How do I do this?
阿神2017-05-16 13:14:38
This can be simplified to 服务器向客户端通信
’s problem.
The ways to solve this problem are (as far as I know):
Websocket
Adobe Flash Socket
AJAX long polling
JSONP Polling
It is recommended to simply implement polling or websocket yourself.
There is also a mature librarysocket.io
, which is used to see SF’s message notifications.
The subject can use the keywords here to search on search engines.
我想大声告诉你2017-05-16 13:14:38
Don’t think about complexity, long connections and communications complicate simple things.
For less demanding scenarios, you can try each N
秒使用AJAX
去服务器取数据(JSON
) and redraw it on the page to achieve your requirements.
If you must ensure real-time, you can only use long connections and communication fields