I have created a function that will return the string "path" from my DB.
function getAudio(mid, cb) {
//mid is an array containing the id to some multimedia files.
for(i=0; i < mid.length; i++) {
db.transaction(function(tx) {
tx.executeSql('SELECT * FROM Multimedia WHERE Mid=' + mid[i] + ' AND Type=' + 2, [], function(tx, results) {
//type=2 is audio. (type=1 is picture file etc) There is only one audiofile in the array.
if(results.rows.length > 0) {
path = results.rows.item(0).Path;
cb(path);
}
}, errorCB);
}, errorCBQuery);
}//end for
}//end getAudio()
When I remove the for-loop, the query is successfull, when the for-loops is there, errorCBQuery or errorCB is called.
Any Ideas on how to fix this? Thanks :)
tx.executeSql('SELECT * FROM Multimedia WHERE Mid=? AND Type=?', [mid[i], 2].