[英]How to get the result from a query function reside in another file? (Javascript, phoneGap and Sqlite)
I wanted to separate my main.js file from my sqlite function file. 我想将main.js文件与sqlite函数文件分开。 How can I get the result of the query to the main.js (fr anotherFile.js).
如何将查询结果获取到main.js(fr anotherFile.js)。
//In main.js
function getResult() {
queryDB(); //how to get d result from queryDB() ?
}
// In anotherFile.js:
function queryDB(tx) {
tx.executeSql('SELECT * FROM DEMO', [], onSuccess, onError);
}
function onSuccess(tx, results) {
for (var i=0; i<result.length; i++) {
//what to put here, Array?
}
}
thanks. 谢谢。
//anotherFile.js:
function queryDB(tx, callbackMethod) {
tx.executeSql('SELECT * FROM DEMO', [], callbackMethod, onError);
}
//main.js
function sendQuery() {
queryDB(tx, queryResult);
}
function queryResult(tx, results) {
for (var i=0; i<result.length; i++) {
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.