Home  >  Article  >  Web Front-end  >  About the use of JS rollback function_html/css_WEB-ITnose

About the use of JS rollback function_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:45:191081browse

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? ? ?


Reply to discussion (solution)

xxxx.query(function (rows){

// Use rows here to get the return value
});

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn