title: How to wait till callback function returns?
body: <p>I'm making an android application using phonegap. I'm using phonegap's Storage api for querying a database. here's my code:</p>
  
  <pre><code>function directPath(src, dest)
  {
      var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
      db.transaction(queryDB, errorCB);
      return arrayroute;
  }
  
  function queryDB(tx)
  {
      tx.executeSql(query, [], querySuccess, errorCB);
  }
  
  function querySuccess(tx,results) {
      //Write some code here.
  }
  
  function errorCB(err) {
      alert("Error in SQL: " + err);
  }
  </code></pre>
  
  <p>The problem is I want to wait till the callback method querySuccess finishes execution before returning from the directPath method.</p>