我想緩存jason數據在本地存儲加載它時沒有互聯網連接它工作正常,但是當我重新啓動應用程序我認爲localstorage清除localStorage不工作whins我重新啓動應用程序 - 電話IOS IOS
這裏是我的代碼
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("offline", function() {
alert("No internet connection");
$.each(JSON.parse(localStorage.getItem('foo')), function(key, val) {
if(!(val.php)){val.php=0;}
$('ul.get-mertchant').append('<li> <a href="azkadenya.html?id=' + val.nid + '&nop='+ val.php +'" class="li-link"><div class="circle-img"><img src="'+ val.logo + '" /></div><div class="merchant-info"><h1>'+ val.node_title +'</h1><p>You Have '+ val.php +' Binggz</p></div><div class="more-icon"></div></a> </li>');
});
}, false);
$.getJSON('mywebsite/views/services_merchant_mobile', function(data) {
localStorage.setItem('foo', JSON.stringify(data));
var items = [];
$.each(JSON.parse(localStorage.getItem('foo')), function(key, val) {
if(!(val.php)){val.php=0;}
$('ul.get-mertchant').append('<li> <a href="azkadenya.html?id=' + val.nid + '&nop='+ val.php +'" class="li-link"><div class="circle-img"><img src="'+ val.logo + '" /></div><div class="merchant-info"><h1>'+ val.node_title +'</h1><p>You Have '+ val.php +' Binggz</p></div><div class="more-icon"></div></a> </li>');
});
})
}
什麼是錯的?
你使用的是什麼版本的phonegap? – 2013-04-09 21:34:21
@JasonFreitas我正在使用cordova 2.3.0 – 2013-04-09 21:36:35
@JasonFreitas是否找出問題所在? – 2013-04-09 22:50:35