【问题标题】:PhoneGap nested executeSql not working in iPad EmulatorPhoneGap嵌套的executeSql在iPad模拟器中不起作用
【发布时间】:2012-02-06 17:39:14
【问题描述】:

不知何故,我的应用程序在 Win-Safari 中完美运行,但不知何故被 PhoneGap 包装时就不行了。这是sn-p:

// working db connection
db.transaction(function(tx) {
  tx.executeSql('SELECT * FROM tbl', [], function(tx, rs){
    // do something with the result

    tx.executeSql('SELECT * FROM another_tbl', [], function(txTwo, rsTwo){
      // do something with the result

      // further nesting ...

    }, errorHandler, successHandler);

  }, errorHandler, successHandler);
}

第一个结果集是正确的,我可以 console.log() 数据。但在那之后,我无法访问第二个嵌套查询的数据。

我没有收到任何错误,并且没有调用我的处理程序(例如 errorHandler)。有趣的是,它不会在 Safari (Win 7) 上造成任何问题

【问题讨论】:

    标签: jquery ipad html sqlite cordova


    【解决方案1】:

    我也遇到过同样的问题。我已经通过在第一次调用 executeSql 的回调中嵌套另一个事务来使其工作(我认为这非常丑陋,但就这样吧)。

    context.db.db.transaction(function(tx) {
        tx.executeSql("SELECT coalesce(sum(pointsawarded),0) as points from eventhistory ", [], function(tx, res) {
            alert('h1' + JSON.stringify(res));
            context.db.db.transaction(function(txsafe) {
                txsafe.executeSql("SELECT coalesce(sum(pointsawarded),0) as points2 from eventhistory ", [], function(tx2, res2) {
                    alert('h2' + JSON.stringify(res2));
                });
             });
         });
    });
    

    【讨论】:

      猜你喜欢
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-02
      • 2017-12-12
      相关资源
      最近更新 更多