Reputation: 875
I think this is quite a noob question, but can't find a direct solution for it. This is my case:
var db = window.openDatabase("database.db", "1.0", "Any_Name", 20000);
db.transaction(queryDB, errorCB);
//-------------------------------------
function queryDB (tx) {
tx.executeSql('SELECT * FROM my_table', [], querySuccess, errorCB);
}
This runs with no problem, but when I try to send extra parameters through the queryDB function I always get an error, I have tried:
db.transaction(queryDB ("hello"), errorCB);
db.transaction(queryDB (db, "hello"), errorCB);
db.transaction(queryDB (tx, "hello"), errorCB);
and
function queryDB (tx, param1) {
tx.executeSql('SELECT * FROM my_table', [], querySuccess, errorCB);
}
I am not sure from where is the queryDB function getting the tx values initially.
Thanks!
Upvotes: 2
Views: 1116
Reputation: 18143
function queryDBWithParam(param1) {
return function(tx) {
//you can use parameter param1
tx.executeSql('SELECT * FROM my_table', [], querySuccess, errorCB);
}
}
db.transaction(queryDBWithParam("hello"), errorCB);
Upvotes: 2