I'm using PhoneGap and a SQLite Database.
I try something like this:
I have a function useSavedThing():
function useSavedThing() {
alert("BEFORE getSavedThing()");
getSavedThing();
alert("AFTER getSavedThing()");
}
and a function getSavedThing():
function getSavedThing(){
alert("ONE");
var db = window.openDatabase("Database", "1.0", "Database", 200000);
db.transaction(populateDB, errorCB, successCB);
alert("TWO");
function populateDB(tx) {
alert("THREE");
}
function errorCB(tx, err) {
alert("Error processing SQL: " + err);
}
function successCB() {
alert("FOUR");
db.transaction(getData);
}
function getData(tx) {
alert("FIVE");
tx.executeSql('SELECT * FROM SETTINGS', [], getIt, errorCB);
}
function getIt(tx, results) {
alert("SIX");
var savedthing = results.rows.item(0).data;
}
}
The problem is that when the function getSavedThing() is called, only the first two alerts (alert("ONE"), alert("TWO)) issued but then the alert ("AFTER getSavedThing ()") called.
But I want that all expenses alert ("ONE"), alert ("TWO"), alert ("THREE") alert ("FOUR") alert ("FIVE"), alert ("SIX"), issued before the alert("AFTER getSavedThing()"); appers.
The order fo the alerts should be:
- alert("BEFORE getSavedThing()");
- alert("ONE");
- alert("TWO");
- alert("THREE");
- alert("FOUR");
- alert("FIVE");
- alert("SIX");
- alert("BEFORE getSavedThing()");
Can someone help me?