this.query = function(callback){
db.transaction(function (tx) {
tx.executeSql("select * from transaction_record", [],
function (tx, results) {
len = results.rows.length;
if(len>0){
for (i = 0; i var row = results.rows.item(i);
console.log('id: '+row.id);
console.log('name: '+row.name);
}
if(typeof(callback) == 'function') {callback(results.rows)}
}else{
if (typeof(callback) == 'function') {callback(false)} //没有数据
}
},function (tx, error) {
return false;
console.log('查询失败: ' + error.message);
});
});
}
如上面代码所示:如何调用上面的方法获取返回值???
xxxx.query(function (rows){
// 这里用rows获取返回值
});