I want to upload 3 websql database table to server. in ajax it sends only first two table values to server and third one is null. if I change order of variables in ajax-data then also it send only first two tables and can not send last table. if i add another table then it send first three tables not last one.
please tell me whats wrong..thanks in advance..
here is javascript:
var db = application.webdb.db;
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM a', [], function (tx, results) {
var data = "";
var a = [];
for (var i = 0; i < results.rows.length; i++) {
var row = results.rows.item(i);
var result = {};
for (var key in row) {
result[key] = row[key];
}
a.push(result);
}
tx.executeSql('SELECT * FROM b', [], function (tx, results) {
var data = "";
var b = [];
for (var i = 0; i < results.rows.length; i++) {
var row = results.rows.item(i);
var result = {};
for (var key in row) {
result[key] = row[key];
}
b.push(result);
}
tx.executeSql('SELECT * FROM c', [], function (tx, results) {
var data = "";
var c = [];
for (var i = 0; i < results.rows.length; i++) {
var row = results.rows.item(i);
var result = {};
for (var key in row) {
result[key] = row[key];
}
c.push(result);
}
var url = "";
url = document.getElementById("url").value;
$.ajax({
type: "POST",
url: url,
async: true,
data: { "a": JSON.stringify(a), "b": JSON.stringify(b) ,"c": JSON.stringify(c)},
// data: { "c": JSON.stringify(c), "a": JSON.stringify(a), "b": JSON.stringify(b) },
error: function (xhr, status, error) { alert(error); },
success: function (data) {
alert("data:" + data);
var sData = JSON.parse(data);
// alert("sData:"+sData);
}//end of sucess
});//end of ajax
});//end of c
});//end of b
});//end of a
});
and php:
<?php
$a = json_decode(stripslashes($_POST['a']),true);
$b = json_decode(stripslashes($_POST['b']),true);
$c = json_decode(stripslashes($_POST['c']),true);
$arr['a'] = $a;
$arr['b'] = $b;
$arr['c'] = $c;
print_r(json_encode($arr));
?>