开发者

In HTML5, how do I return the results of an SQLite call directly, rather than handing them to a function?

开发者 https://www.devze.com 2023-01-23 01:45 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消