我有一個小應用程序,它使用WebSQL進行數據存儲。
我想同步這個數據與網絡服務器(PHP + MySQL)
我的主要問題是,我不知道如何從WebSQL創建一個JSON來傳輸它。我怎樣才能得到JSON fton WebSQL
//view the result from DB on a web-page
$('body').html('<ul id="dataAllHere"></ul>')
mybase.init.getAll = function(){
var database = mybase.init.db;
database.transaction(function(tx){
tx.executeSql("SELECT * FROM table", [], function(tx,result){
for (var i=0; i < result.rows.length; i++) {
item = result.rows.item(i).item;
due_date = result.rows.item(i).due_date;
the_type = result.rows.item(i).the_type;
id = result.rows.item(i).ID;
showAll(item,due_date, the_type, id);
}
});
});
}
function showAll(item,due_date, the_type, id){
$('#dataAllHere').append('<li>'+item+' '+due_date+' '+the_type+' '+id+'</li>');
}
mybase.init.getAll();
我對JSON並不十分熟悉,我會很樂意提供任何幫助和建議。
謝謝!
TYWM! 奇怪,但它告訴我myJson是未定義的。 –