Home > Article > Web Front-end > About the use of JS rollback function_html/css_WEB-ITnose
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 < len; 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)} //No data
}
}, function (tx, error) {
return false;
console.log('Query failed: ' error.message);
});
});
}
As shown in the above code: How to call the above method to get the return value? ? ?
// Use rows here to get the return value
});