title: jquery 1.10 $.ajax with $.each call to finish (phonegap)
body: <p>I am having a problem with my ajax calls in jquery and keeping the screen showing a loading icon until 100% finished processing.</p>
  
  <p>I am using this with phonegap and the database, so that items pulled from ajax are loaded into the database.  The code runs fine and the database is 100% populated,  but my "#block-ui" is disapparing before the database $.each calls 100% complete.  Also my #sync text shows in random order.</p>
  
  <p>Since I am using jquery 1.10, I know async: false no longer works.  Can someone help.</p>
  
  <pre><code>function SyncIt() {
      $('#recap').text('');
      $('#syncit').attr("href", "#");
      var db = window.openDatabase("titanware", "1.0", "TitanRoof", 50000000);
      $('#block-ui').show();
      $('#sync').text('Syncing with Titanware');
      db.transaction(function(tx) {tx.executeSql('DELETE FROM active_jobs WHERE jb_active != 1');},dbErrorHandler);
      db.transaction(function(tx) {tx.executeSql('DELETE FROM employees');},dbErrorHandler);
  
  // Sync Jobs    
      $.ajax({
      type: 'GET',
      url: 'http://xxxxxxxxx/api/api.php?request_type=m_clients',
      crossDomain: true,
      contentType: "application/json; charset=utf-8",
      dataType: "jsonp",
      cache: false,
      success: function(data) {
      $('#sync').text('Syncing Jobs');
      }
      }).done(function(data) {
  
      $.each(data, function (i, item) {
      // Load Data into the database for jobs        
      db.transaction(function(tx) {tx.executeSql("insert into active_jobs(job_no, comp_name, comp_street, comp_suite, comp_city, comp_state, comp_zip, comp_contact, comp_phone, comp_cell, comp_notes, jb_active) values(?,?,?,?,?,?,?,?,?,?,?,?)", [item.job_no,item.comp_name,item.comp_street,item.comp_suite,item.comp_city,item.comp_state,item.comp_zip,item.comp_contact,item.comp_phone,item.comp_cell,item.comp_notes,'0']);},dbErrorHandler);
  
      })
  
      db.transaction(function(tx){
      tx.executeSql('SELECT * FROM active_jobs', [], function(tx, results) {
      var len = results.rows.length;
      // Show total jobs synced in the #recap div
      $('#recap').text('Jobs Synced: ' + len);
      });
      });
  
      });
  
  // Sync Employees   
      $.ajax({
      type: 'GET',
      url: 'http://xxxxxxx/api/api.php?request_type=get_employees',
      crossDomain: true,
      contentType: "application/json; charset=utf-8",
      dataType: "jsonp",
      cache: false,
      success: function(data) {
      $('#sync').text('Syncing Employees');
      }
      }).done(function(data) { 
      $.each(data, function (i, item) {
      //Load employees in the database  
      db.transaction(function(tx) {tx.executeSql("insert into employees(user_id, full_name) values(?,?)", [item.user_id,item.full_name]);},dbErrorHandler);
  
      })
  
      $('#sync').text('Almost Done'); 
      $('#block-ui').hide();
  
      });
  
  }
  </code></pre>
  
  <p>Thanks for any feedback</p>