缓存清单导致$ .getJSON停止 [英] Cache manifest causes $.getJSON to stop
问题描述
我正在使用HTML5,Javascript,jQuery Mobile和离线存储开发移动应用。
I am developing a mobile app using HTML5, Javascript, jQuery Mobile, and offline storage.
我有一个wep应用程序,它提供一系列JSON对象到移动应用程序(在同一个域上)。它获取JSON对象,将它们存储在websql数据库中,然后用它们创建一个无序列表,可以点击它...
I have a wep app that serves an array of JSON objects to the mobile app (on the same domain). It gets the JSON objects, stores them in a websql database then creates a unordered list with them which can be clicked...
这个想法是当设备在离线模式我将从离线数据库中提取数据并绕过从Web应用程序获取JSON,然后当设备下次在线时,它可以获得数据的新副本。
The idea is that when the device is in offline mode I will pull the data from the offline database and bypass getting the JSON from the web app, then when the device is next online it can get a fresh copy of the data.
我已经到了创建cache.manifest文件的部分。基本上它看起来像这样:
I've got to the part where I am creating my cache.manifest file. Basically it looks like this:
CACHE MANIFEST
CACHE:
index.html
app.html
NETWORK:
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
但是只要我添加
<html manifest="cache.manifest">
并重新加载我的$ .getJSON停止的页面(可以在data.js中找到)。该文件中的其他JS代码似乎执行但该功能。
And reload the page my $.getJSON stops (can be found in data.js). Other JS code in that file seems to execute but that function.
这是在加载时执行的函数:
Here is the function that gets executed on load:
function getAppointments(){
// Update appointments ONLY when online
if(navigator.onLine = true){
console.log('Application Online.')
// create appointments table
createAppTable();
$.getJSON("http://site.com/OptiQuoteApp/index.php/appointments/download/", function(data) {
$.each(data,function()
{
// Save appointments in database
updateAppointments(this.quote_id, this.start_date, this.reference, this.first_name+' '+this.last_name, this.comment);
});
getAppointmentsList();
});
}else{
console.log('Application Offline.')
}
getAppointmentsList();
}
注意。我知道它说site.com(为了安全...)
Note. I know it says site.com (for security...)
脚本到createAppTable();然后没有了。
The script gets as far as createAppTable(); then no more.
任何人都知道吗?
Billy
非常感谢
推荐答案
尝试在清单文件中的NETWORK:下添加*。这样,任何未经过专门缓存的内容都将从您的网站中撤出。
Try adding * under "NETWORK:" in your manifest file. That way anything not specifically cached will get pulled from your site.
NETWORK:
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
*
这篇关于缓存清单导致$ .getJSON停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!