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 ',
开发者_JAVA技巧 [],
function(transaction, results) {
// would like to return the "results" back
},
errorHandler
);
});
// code to use the "results" array
} catch(e) {
alert(e.message);
}
You can't. Because JavaScript is asynchronous, it doesn't give you any way to block until a blocking operation completes.
精彩评论