views:

40

answers:

1

Hello.

Using SQLite in HTML5, how do I execute a call such as the following so that it's returned immediately, instead of passing off the result to another function?

try {
    mydb.transaction( function(transaction) {
        transaction.executeSql(
            'SELECT name FROM celebs order by name limit 100 ',
            [],
            function(transaction, results) {
                // would like to return the "results" back
            },
            errorHandler
        );
    });
    // code to use the "results" array
} catch(e) {
    alert(e.message);
}
A: 

You can't. Because JavaScript is asynchronous, it doesn't give you any way to block until a blocking operation completes.

David Wolever
thanks for the answer
Joe