I m tri开发者_运维知识库ng to implement ajax polling in my code but i want to make sure that the server has an update before requesting for the data.How can I accomplish this?
the entire point of polling is you don't know if the server is ready. If you knew, you wouldn't have to poll...
One thing you can do to make the load on the server lighter is increase the interval between polls the longer it takes. So, initially poll every 2 seconds, but after say five tries, go to five seconds, and after five tries, maybe give up and give a message. Depends on your specific use case though...
精彩评论