开发者

Using Ajax with Offline Cache

I'm working on an offline-capable application and I'd like to do an ajax call to $.get() a file on the domain that I will be caching.

Will the call still work if I'开发者_Python百科m offline? I would presume no, but I wondered if I included the static page in the offline cache if it would somehow still work.


Short answer: Yes.

If you have the file in the application cache, then all HTTP GET requests (including Ajax) will go through the cache. You can think of an Ajax GET request as an ordinary browser page load, but the results are delivered to your code rather than directly to the user.


You can cache the responses into local storage and use the saved one when offline. See more on how to make this automatic here: http://myok12.wordpress.com/2011/08/19/building-an-almighty-data-retrieval-system-for-all-html5-webapps/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜