我正在開發一個使用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();那麼沒有更多。
任何想法的人?
比利
非常感謝
你有沒有在這裏錯過'==':'navigator.onLine = true'? –
另外,也許一些相關的信息在https://github.com/jquery/jquery-mobile/issues/1579 –
評論您好凱文,我意識到,我發佈後,但改變它並沒有解決問題。雖然 – iamjonesy