title: HTML5 WebSQL: how to know when a db transaction finishes?
body: <p>I've the following code that gets a json recordset and insert some data in three different tables on the client Web Sql storage.</p>
  
  <p>How can I intercept the end of databaseSync() function?
  What I want to do is display an alert or better an ajax spinner gif in order to inform the user when the sync is complete.</p>
  
  <p>Many thanks for your help,
  ciao!</p>
  
  <pre class="lang-js prettyprint-override"><code>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);
                  });
              });
          });
  
  
      }
  </code></pre>