我需要将一些数据从我的 Phonegap 应用程序同步回服务器。我在服务器上有一个 PHP 脚本来接收数据,我需要能够从我的应用程序中向它发布一些值。
我将我的数据存储在 SQLite 数据库中,我想将其输出并 AJAX 将其输出到服务器。
我似乎没有将任何数据发送到 PHP 脚本,并且 onSuccess 函数只是返回它正在发送的数据的副本,而不是来自服务器的响应。如果我控制台记录 currentRow 对象,它会按预期返回每行的数据字符串。
有人可以指出我正确的方向吗?
这是数据库查询和 AJAX 调用...
var query = "SELECT * FROM fixturesfittings WHERE propertyid = ?;"
localDatabase.transaction(function (trxn) {
trxn.executeSql(query, [propertyid], function (transaction, thedata) {
var i = 0,currentRow;
for (i; i < thedata.rows.length; i++) {
currentRow = thedata.rows.item(i);
$.ajax({
type: "POST",
url: "http://myserver.com/putData.php",
cache: false,
dataType: "text",
data: currentRow,
success: function(mydata) {
$("#resultLog").append(mydata);
},
error: function() {
$("#resultLog").html("Error");
}
});
}
},errorHandler);
});