How can access the results of a
tx.executeSql('select query for a table',[],sucessCB);
function sucessCB(tx, results){ //<--- this results param
console.log(results.row.item(0).name);
}
I tried something like
function(){
var tab = [];
tx.executeSql('select query for a table',[],sucessCB);
function sucessCB(tx, results){ //<--- this results param
console.log(results.row.item(0).name);
for(i=0;i<results.length;i++){
tab.push(results.row.item(i))
}
}
console.log(tab); //<--- this returns always null
}
how can access the variable outside the callback function or is there a way to store a sql results in variable directly. Is there a way to send variable into a callback function again in the
tx.executeSql('another select query',[],function(tx, results, tab ){ // <-- this inside sucessCB
console.log(tab);
});
In all the scenario the variable is null. Is there a another way to do this. Any suggestion would be helpful thanks.
You use callback as follow:
However this kind of problem is better solved by using Deferred concept.