I posted a question about why my $.getJSON had stopped but I think the question is a bit wider now.
I have a mobile HTML5 app that does Ajax requests to a php web app (on the same domain). When there is an internet connection ie. navigator.onLine == true I do a $.getJSON call to the web app and store the response locally in a websql db on the device's browser.
If navigator.onLine == false then I want to skip the json request and pull data out locally instead. My JSON works and I'm storing successfully in offline websql storage but my problem comes when adding the cache manifest file.
I'm not sure how to cache what I'll need. Here is my cache manifest:
CACHE MANIFEST
# rev 2
CACHE:
index.html
app.html
http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js
http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css
http://code.jquery.com/jquery-1.4.3.min.js
js/data.js
js/script.js
I think I'm right in assuming I can cache external files from code.jquery.com/..? Because I will need them online and offline.
Eric posted an answer in my previous question saying I should add the JS files under the NETWORK: heading with * at the end. When I do that my JSON call is triggered like I want it to. However now the files are unavailable offline.
This seems to work as well but when I go offline not even my CSS is loaded:
CACHE MANIFEST
# rev 2
CACHE:
index.html
app.html
js/data.js
http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js
http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css
http://code.jquery.com/jquery-1.4.3.min.js
js/script.js
NETWORK:
*
Can anyone suggest the best practice for caching javascript/css files for offline use?
Thanks a lot,
Billy