I can not understand why my global variable declared in function remains empty at the end of function despite the fact that it was changed inside the transaction
Please help to return the result of the transaction back in to my function
function () {
var db;
var rowsNameList = [];
db = openDatabase('cwdb', '1.0', '', 10 * 1024 * 1024);
function getRowsNames(result){
for (var i = 0; i < result.rows.length; i++) {
for (var rowName in result.rows[i]) {
rowsNameList.push(rowName);
}
}
};
db.transaction(function (tx) {
tx.executeSql("SELECT * FROM TreeEls WHERE parent = '#'",
[],
function (tx, result) {
console.info(result)
getRowsNames(result);
console.log(rowsNameList);
},
function (tx, error) {
}
);
});
console.log(rowsNameList);
return {}
Inside transaction console.log shows that array consists of 5 elements, so i have used global variable, but console.log at the end of function shows empty array and i have no idea why?