Getting Results from a Web SQL database
- by andrew8088
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?