Getting Results from a Web SQL database
        Posted  
        
            by andrew8088
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by andrew8088
        
        
        
        Published on 2010-04-24T16:50:57Z
        Indexed on 
            2010/04/24
            16:53 UTC
        
        
        Read the original article
        Hit count: 167
        
JavaScript
I'm playing around with the new Web SQL databases. Is there a way to return results from a SELECT statement? Here's my example:
function getTasks (list) {
  db.transaction(function (tx) {
   list = list || 'inbox';
   tx.executeSql("SELECT * FROM tasklist WHERE list = ?", [list], function (tx, results) {
    var retObj = [], i, len = results.rows.length;
    for ( i = 0; i < len; i++ ) {
     retObj[i] = results.rows.item(i);
    }
    return retObj;
   });
  });
 }
The getTasks function is returning before the success callback does; is there a way to get the results out of the executeSql method, or do I have to do all the processing within the callback?
© Stack Overflow or respective owner