Q:

HTML5 Local Database Callback

I'm inserting hundreds of rows into a Local Database.  
After this insert, I would like to SELECT * from that table to get and display all these records.  
I tried putting the Select statement in the callback of the INSERT transaction, but it isn't working properly.  I tested the SELECT statement to see that it works, when I do a page refresh.  
Can anyone help? After all the records are inserted, I want to be able to SELECT them all without refreshing the page.  Thanks!
database.db.transaction(function (tx) {
                    JSON PROCESSING                            
                tx.executeSql('INSERT INTO ...'),
                    [DATA IS HERE],

                    function (tx, callback) {
                        alert(callback.message);

                        database.db.transaction(function (tx) {
                        tx.executeSql('SELECT * from table;', [], tableSelectHandler, errorHandler);
                                        });
                                    },
                    function (tx, error) {
                         alert(error.message);
                    }

            });

A:

It's a bit late to answer this particular question, but could help somebody, so...
The db.transaction function also has callback functions for Error and Success. You can place your SELECT code in the Success callback, and it will be executed at the end of the transaction, after all the Inserts are executed. Basically you should have something like this:
database.db.transaction(function (tx) { //JSON PROCESSING

    tx.executeSql('INSERT INTO ...'),
        [DATA IS HERE],
    function (tx, callback) {
        alert("Insert ok");
    },
    function (tx, error) {
        alert("Error inserting: " + error.message);
    }
},
function (error) { // This is the Error callback of the TRANSACTION
     alert(error.message);
},
function (result) { // This is the Success callback of the TRANSACTION
    alert("TRANSACTION completed");

    database.db.transaction(function (tx) {
        tx.executeSql('SELECT * from table;', [], tableSelectHandler, errorHandler);
    }); // Your tableSelectHandler should take care of the result of the Select
});

Hope it helps. Cheers!

