私はモバイルアプリです。私は、Ajaxは、このコードをウェブサーバからデータを受信するために呼び出して使用します。完了後にjquery ajaxコールを一度実行する
$.ajax({
url: 'http://www.xxxxxxxxxxxx',
data: {name: 'Chad'},
dataType: 'jsonp',
success: function(data){
$.each(data.posts, function(i,post){
$.mobile.notesdb.transaction(function(t) {
t.executeSql('INSERT into bill (barcode, buildingcode, buildingaddress, flatname, flatdescription, entryseason, period, amount, pastpayments, todaypayments, receiptno) VALUES (?,?,?,?,?,?,?,?,?,?,?);',
[post.Id, post.Code, post.Address, post.Name, post.Description, post.EntrySeason, post.Period, post.Revenue, post.PastPayments, post.todaypayments, post.receiptno],
function(){
bill = 1;
$('#mycontent').append("bill - OK");
}
);
});
});
}
});
私はbill - OK
はsqliteのに挿入されたすべてのデータの後に一度だけ表示します。
$.ajax({
url: 'http://www.xxxxxxxxxxxx',
data: {name: 'Chad'},
dataType: 'jsonp',
async: false, //this line here
//...
EDITかについて
OK、::
$.each(data.posts, function(i,post){
//rest of stuff
});
$('#mycontent').append("bill - OK"); //this line outside the each() call
をそして、あなたの実際の問題が..です? –
bill - sqliteへの挿入のたびにOKが表示されます... 20回 – kosbou
'$ .each'ループの外にあなたの" bill - OK "行を移動します。 – SenorAmor