如何解决websql 异步问题,求示例
1个回答
展开全部
functiongetFolder(id, callback) {
vardata = [];
ldb.transaction(function(tx) {
tx.executeSql('SELECT * FROM folders where id=?',
[id],
function(tx, results) {
if(results.rows && results.rows.length) {
for(i = 0; i < results.rows.length; i++) {
data.push(results.rows.item(i));
}
}
if( typeof(callback) == 'function') callback(data);
},
function(tx, error) {
console.log(error);
});
});
vardata = [];
ldb.transaction(function(tx) {
tx.executeSql('SELECT * FROM folders where id=?',
[id],
function(tx, results) {
if(results.rows && results.rows.length) {
for(i = 0; i < results.rows.length; i++) {
data.push(results.rows.item(i));
}
}
if( typeof(callback) == 'function') callback(data);
},
function(tx, error) {
console.log(error);
});
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询