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

有人知道吗?

比利

非常感激

最佳答案

尝试在清单文件的“ 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
*

07-24 09:50
查看更多