Кажется, это не просто, и не должно быть все так сложно, но через два дня я нахожусь в тупике.Я не могу понять, почему этот цикл выполняется дважды.
db = openDatabase("com.xyz.mobile.db", "", "The App Database", 5 * 1024 * 1024);
db.transaction(function(tx) {
tx.executeSql("SELECT * FROM somedata", [], function(tx, result) {
c = (result.rows.length - 1); //result.rows.length = 2 there are only 2 records
console.log("c = " + c); // outputs 1 in console
for(var i = 0; i < result.rows.length; i++) {
console.log("i = " + i);
console.log(result.rows.item(i)['description']);
if(i == c){
console.log("I will run twice just to make you pound on key board");
break;
}
}
}, null);
});
Вот что я получаю в консоли Chrome:
c = 1
i = 0
2/30/2012 22:02:08
i = 1
2/30/2012 22:02:27
I will run twice just to make you pound on key board
c = 1
i = 0
2/30/2012 22:02:08
i = 1
2/30/2012 22:02:27
I will run twice just to make you pound on key board
Помоги мне, Оби Ван, твоя единственная надежда.