我有以下代码,它获取一个 json 记录集并在客户端 Web Sql 存储上的三个不同表中插入一些数据。
如何拦截 databaseSync() 函数的结束?我想要做的是显示警报或更好的 ajax spinner gif,以便在同步完成时通知用户。
非常感谢您的帮助,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);
});
});
});
}