現在、Web SQL 行を処理する次のコードがあります。現在、すべての行に対してサーバーにリクエストを送信します。どうにかしてすべての行を多次元の JSON オブジェクトにマージしたいのですが、その方法に関するドキュメントが見つからないようです。
結果をループするときに、オブジェクトに「追加」する方法はありますか?
$("#sync-surveys").click(function(){
$.mobile.showPageLoadingMsg();
db.transaction(function(tx) {
tx.executeSql("SELECT * FROM surveys", [], function(tx, result) {
for (var i = 0, item = null; i < result.rows.length; i++) {
item = result.rows.item(i);
var json_str = JSON.stringify(item);
$.ajax({
type: "post", url: "/survey/survey/process_survey",
data: json_str,
success: function (data) {
alert("saved successfully");
$.mobile.hidePageLoadingMsg();
},
error: function (data) {
alert(data.responseText);
$.mobile.hidePageLoadingMsg();
//console.log(data);
}
});//End ajax function
}//End results loop
});
});//End Transaction
});//End Surveys Click