缓存清单导致 $.getJSON 停止
我正在使用 HTML5、Javascript、jQuery Mobile 和离线存储开发移动应用程序。
我有一个 wep 应用程序,它向移动应用程序(在同一域上)提供 JSON 对象数组。它获取 JSON 对象,将它们存储在 websql 数据库中,然后使用它们创建一个可以单击的无序列表...
这个想法是,当设备处于离线模式时,我将从离线数据库中提取数据并绕过获取来自 Web 应用程序的 JSON,然后当设备下次上线时,它可以获得数据的新副本。
我已经到了创建cache.manifest 文件的部分了。基本上它看起来像这样:
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 代码似乎执行但该函数。
这是在加载时执行的函数:
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 (出于安全考虑...)
该脚本最多可达 createAppTable();然后就没有了。
有人有什么想法吗?
比利
非常赞赏
I am developing a mobile app using HTML5, Javascript, jQuery Mobile, and offline storage.
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...
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.
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
However as soon as I add
<html manifest="cache.manifest">
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();
}
Note. I know it says site.com (for security...)
The script gets as far as createAppTable(); then no more.
Any idea anyone?
Billy
Much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在清单文件的“网络:”下添加 *。这样,任何未专门缓存的内容都会从您的网站中提取。
Try adding * under "NETWORK:" in your manifest file. That way anything not specifically cached will get pulled from your site.