Phonegap: cannot execute multiple SQL queries on one page

I have different buttons on my page, and each time I click on it, different requests will be generated to access the database. I already had one "queryDB" function to retrieve all the data in the table, and when I press the reset button, another query to UPDATE the table values.

I noticed that DID NOT went to FUNCTION " resetDB ". Is it because the phoneGap function uses only the queryDB function? How do i solve this?

*** New found problem ** I understand that when I use location.reload (), it does not update the table. Therefore, I did not use it, it went into the function and updated the database, but did not show the β€œnew” page. If I use href on the settings page, it will not update the database as before.

$('button#reset').on("click",function(){ var db = window.openDatabase("Database", "1.0", "ApplicationDB", 200000); db.transaction(resetDB, errorCB); location.reload(); }); 

ResetDB function

 function resetDB(tx) { tx.executeSql("UPDATE RESULT SET Difficulty = 'Easy' " , [], querySuccess, errorCB); } 

Function Request DB

 function queryDB(tx) { tx.executeSql("SELECT * FROM RESULT ORDER BY Level" , [], querySuccess, errorCB); } 
+4
source share
2 answers

I need to download the same page again to display updated information from the database.

I believe this should work for you.

 $('button#reset').on("click",function(){ var db = window.openDatabase("Database", "1.0", "ApplicationDB", 200000); db.transaction(resetDB, errorCB, successCB); }); // Success callback function successCB() { location.reload(); } 
+1
source

If you use jQueryMobile and want to go to the same page, do the following:

$. mobile.changePage (hashedPage, {allowSamePageTransition: true});

Could you also add more code to understand the location object?

+1
source

All Articles