I understand this is a very old question, but I found it when I was looking for how to handle asynchronous SQLite calls in JavaScript. And the question is the same as mine, and I found the best answer (unfolds according to the selected answer, using closure)
my version of your getData function is as follows:
function get_option (option, get_option_callback){ if (db === null){ open_database(); } db.transaction(function (tx) { tx.executeSql("SELECT rowid,* FROM app_settings WHERE option = ? ", [option], function(tx, result){ item = result.rows.item(0); get_option_callback(item.value); return; } }, sql_err); }); }
Then, to call the method, I would use:
get_option("option name", function(val){
adbe
source share