简体   繁体   中英

How to keep listen server with jquery ajax?

How to refresh or update my content through jquery ajax when ever server changes the code?

Remember:-

  1. Take this stackoverflow page as example of what i am looking for. It updates its content with out clicking anywhere, With out any timeout or time interval functions. So like this page i am looking for.
  2. I am working on cordova, so that i can get access from server only via jquery ajax. So how to invoke JS functions from server or only if server content changes?

There are two ways you can do.

  1. Web Sockets . Using the HTTP 101 Switching Protocols, you can have a persistent connection to the server and work out on the changes to the view.
  2. Long Polling . If your server is hard enough for no DDoS attacks, you can use this method to continuously ping the server, and get the latest info.

Does the above two methods help? There are other articles that help you in differentiating Web Sockets and Long Polling:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM