小编del*_*lmi的帖子

HTML5 WebSQL:如何知道db事务何时完成?

我有以下代码获取json记录集并在客户端Web Sql存储上的三个不同表中插入一些数据.

如何拦截databaseSync()函数的结束?我想要做的是显示一个警报或更好的ajax微调器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) …
Run Code Online (Sandbox Code Playgroud)

database jquery html5 web-sql

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

database ×1

html5 ×1

jquery ×1

web-sql ×1