p>
function directPath(src, dest)
{
var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
db. transaction(queryDB, errorCB);
return arrayroute;
}
function queryDB(tx)
{
tx.executeSql(query, [], querySuccess, errorCB);
}
function querySuccess(tx,results) {
//Write some code here.
}
function errorCB(err) {
alert("Error in SQL: "+ err);
}
The problem is that I want to wait until the callback method querySuccess finishes execution before returning from the directPath method .
I am using phonegap to make an Android application. I am using phonegap’s Storage api to query the database. This is my code:
function directPath(src, dest)
{
var db = window.openDatabase("Database", "1.0", "PhoneGap Demo" , 200000 );
db.transaction(queryDB, errorCB);
return arrayroute;
}
function queryDB(tx)
{
tx .executeSql(query, [], querySuccess, errorCB);
}
function querySuccess(tx,results) {
//Write some code here.
}
function errorCB(err) {
alert("Error in SQL: "+ err);
}
The problem is that I want to wait until the callback method querySuccess Finish execution before returning from the directPath method.
Don’t try to fight against asynchrony: your application may eventually appear to be unresponsive to the user. For any code that must be executed later , Please use querySuccess callback.