I'm trying to run a check on a webdb running on a cordova/jQuery-mobile application:
This function will check whether the table exists in the DB and subsequently return a true or false. I have tried to change the return type from boolean to integer (0 and 1) but with no success.
function checkConfigTable(tablename) {
db.transaction
(
function (tx)
{
tx.executeSql
(
'SELECT name FROM sqlite_master WHERE type="table" AND name=?',
[tablename],
function(tx,results)
{
var len = results.rows.length;
if(len>0)
{
return true;
}
else {
return false;
}
}, errorCB
);
},errorCB,successCB
);
}
I want to then call checkConfigTable from this other one just to alert the return value (only for test purposes at the moment) but I am always getting "undefined" as return value.
// Function to retrieve current login config
function getSavedLogin(configid) {
var x = checkConfigTable("config");
alert('table: ' + x);
}
If I substitute the return with an alert directly in checkConfigTable() the correct values are shown in the alert box.
Aucun commentaire:
Enregistrer un commentaire