function queryDB(callback) {
$.blockUI({css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}});
var sqlTxt = "SELECT * FROM ITEMS";
db.transaction(
function(tx) {
tx.executeSql(sqlTxt, [],
function(tx, results) {
for (var i = 0; i < results.rows.length; i++) {
item_Codes.push({item_code: results.rows.item(i).itemCode, description: results.rows.item(i).description, price: results.rows.item(i).price});
}
callback(item_Codes);
})
, errorCB;
});
return false;
}
我需要在此方法开始之前开始加载消息,并且该方法结束我需要停止它。我尝试上面的代码但是它从方法开始而不是在方法之前
答案 0 :(得分:0)
试试这个:
function queryDB(callback) {
$.blockUI({css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}});
setTimeout(function(){
var sqlTxt = "SELECT * FROM ITEMS";
db.transaction(
function(tx) {
tx.executeSql(sqlTxt, [],
function(tx, results) {
for (var i = 0; i < results.rows.length; i++) {
item_Codes.push({item_code: results.rows.item(i).itemCode, description: results.rows.item(i).description, price: results.rows.item(i).price});
}
callback(item_Codes);
})
, errorCB;
});
},0);
return false;
}