I've been working on retrieving column values from a database and storing them in an array, but I keep getting an empty array as the result.
function FetchData(query, db) {
var resultArray = new Array();
db.transaction(function(tx) {
tx.executeSql(query, [], function(tx, rs) {
var length = rs.rows.length;
for (var i = 0; i < length; i++) {
var row = rs.rows.item(i);
resultArray.push({latitude : row['latitude']});
}
});
});
return resultArray;
}
Even though I can see the array being populated inside the for loop, it ends up empty when returned.