关于JS 回掉函数的使用_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:45:19
Original
1042 people have browsed it

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获取返回值
});

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!