作業中のデータベース アプリケーションで問題が発生しています。SQL トランザクションが完了する前に、JavaScript 関数が進行し続けているようです。以下は、私が経験していることの非常に単純化されたバージョンです。実際の関数では、for ループの次の値に移動する前に、テーブルでいくつかの作業を実行しようとしています。forループですべてを実行してから、SQLトランザクションを完了するようです。
サンプルコードは次のとおりです。
function fillTables(){
    db.transaction(function (tx){
        for(var i=0; i<3; i++){
            console.log('Filling row '+i);
            tx.executeSql(
                        'INSERT INTO Numbers (Value) VALUES (?)',
                        [i],
                        function (){
                            console.log('Inserted Row');    
                        },
                        errorCB);
            console.log('moving on...');
        }
    });
}
私が期待するコンソールログは次のようになります。
Filling Row 0
Inserted Row
moving on...
Filling Row 1
Inserted Row
moving on... 
Filling Row 2
Inserted Row
moving on... 
しかし、私は得ています:
Filling row 0 
moving on... 
Filling row 1 
moving on... 
Filling row 2 
moving on... 
Inserted Row 
Inserted Row 
Inserted Row 
どうすれば望ましい結果を達成できるかについてのアイデアはありますか?