缓存清单导致$.getJSON停止

Cache manifest causes $.getJSON to stop

本文关键字:getJSON 停止 单导致 缓存      更新时间:2023-09-26

我正在使用HTML5, Javascript, jQuery mobile和离线存储开发一个移动应用程序。

我有一个wep应用程序,为移动应用程序提供JSON对象数组(在同一域上)。它获取JSON对象,将它们存储在websql数据库中,然后用它们创建一个无序列表,可以单击…

这个想法是,当设备处于离线模式时,我将从离线数据库中提取数据,并绕过从web应用程序获取JSON,然后当设备下一次在线时,它可以获得数据的新副本。

我已经到了创建缓存的部分。清单文件。基本上是这样的:

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();

有人知道吗?

比利

感谢

尝试在manifest文件"NETWORK:"下面添加*。这样,任何没有特别缓存的内容都将从您的站点中删除。

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
*