0
현재 웹 SQL 행을 처리하는 데 다음 코드가 있습니다. 현재는 모든 행에 대해 서버에 요청을 보냅니다. 어떻게 든 모든 행을 다차원 JSON 객체에 병합하고 싶습니다. 그러나이를 수행하는 방법에 대한 문서를 찾을 수없는 것 같습니다.JSON 문자열을 병합하여 AJAX를 간소화하십시오.
결과를 반복하면서 개체에 "추가"할 수있는 방법이 있습니까?
$("#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
http://api.jquery.com/jQuery.extend/ – adeneo