我有一个小应用程序,它使用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是未定义的。 –