I am developing a mobile app. I use ajax calls to receive data from a webserver with this code:
$.ajax({
url: 'http://www.xxxxxxxxxxxxxxxx',
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],
//$.mobile.changePage('#page3', 'slide', false, true),
null);
});
});
},
complete: function() {
test = 1;
}
});
I want the complete function to be executed after all data inserted to SQLite...
How can I do this?