gpt4 book ai didi

javascript - 缓存 list 导致 $.getJSON 停止

转载 作者:行者123 更新时间:2023-11-28 21:19:35 25 4
gpt4 key购买 nike

我正在使用 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();然后就没有了。

有人知道吗?

比利

非常感谢

最佳答案

尝试在 list 文件的“网络:”下添加 *。这样,任何未专门缓存的内容都会从您的网站中提取。

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
*

关于javascript - 缓存 list 导致 $.getJSON 停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6736275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com