如何从波纹管内部匿名函数返回值。
function getDayFromCalendar() {
var db = openDatabase('Calendar', '1.0', 'myapp', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM calendar LIMIT 1', [], function (tx, results) {
return results.rows.item(0).date;
});
});
}
答案 0 :(得分:0)
function getDayFromCalendar() {
var db = openDatabase('Calendar', '1.0', 'myapp', 2 * 1024 * 1024);
var outerResult = db.transaction(function (tx) {
var innerResult = tx.executeSql('SELECT * FROM calendar LIMIT 1', [], function (tx, results) {
return results.rows.item(0).date;
});
// here you have inner function result
return innerResult;
});
// here you have outer function result
alert(outerResult);
}