Here is my code:
var resultSet;
db.transaction(function (tx){
tx.executeSql('SELECT * FROM table WHERE name = ?', [name], function (tx, results) {
resultSet = results;
});
});
console.log(resultSet);
What is logged is “undefined”.
What I am hoping to get is the SQLResultSet object “results” assigned to “resultSet”.
I am sure I am misunderstanding scoping in JavaScript. But this seems like it should work and I can’t find a similar question asked.
Thanks for your time!!
Either
transactionorexecuteSqlis an asychronous function, meaning anything involving its result MUST be included in the callback function.