HTML5 WebSQL: como saber quando uma transação db termina?
Eu tenho o código a seguir que obtém um conjunto de registros json e insere alguns dados em três tabelas diferentes no armazenamento de SQL da Web do client
Como posso interceptar o final da função databaseSync ()? O que eu quero fazer é exibir um alerta ou melhor um gif do ajax spinner para informar o usuário quando a sincronização estiver concluíd
Muito obrigado pela sua ajuda, ciao!
function databaseSync() {
// table one
$.getJSON("http://192.168.1.40:8888/iOS/mobilesrv/index.php?ACT=one", function(json) {
$.each(json.results, function(i, res) {
db.transaction(function(tx) {
tx.executeSql("INSERT INTO table1 (A, B, C, D) VALUES (?,?,?,?) ", [res.A, res.B, res.C, res.D], onSuccess, onError);
});
});
});
// table two
$.getJSON("http://192.168.1.40:8888/iOS/mobilesrv/index.php?ACT=two", function(json) {
$.each(json.results, function(i, res) {
db.transaction(function(tx) {
tx.executeSql("INSERT INTO table1 (A, B, C, D) VALUES (?,?,?,?) ", [res.A, res.B, res.C, res.D], onSuccess, onError);
});
});
});
// table three
$.getJSON("http://192.168.1.40:8888/iOS/mobilesrv/index.php?ACT=three", function(json) {
$.each(json.results, function(i, res) {
db.transaction(function(tx) {
tx.executeSql("INSERT INTO table1 (A, B, C, D) VALUES (?,?,?,?) ", [res.A, res.B, res.C, res.D], onSuccess, onError);
});
});
});
}