I am working with phonegap+sqlite.
I am trying to insert something.
Here is the code-
function insertDB() {
var sqlI = "INSERT INTO post_data(post_text,pdate) VALUES("Hello, world","23-05-2012");
mydb.transaction(
function(transaction) {
transaction.executeSql(sqlI, [], nullDataHandler, errorHandler);
});
console.log("inserted");
window.location="dashboard.html";
}
I am able to insert data when I remove the line window.location="dashboard.html" or when i set a delay of 1000ms, and then execute window.location="dashboard.html". But the above code does not work. Why?
I think that the
transactionfunction is asynchronous.Try and put the redirection just above :
As you can see, the redirection would be handled in the resultHandler.