javascript - No database is running on event click -
this code working.
tx.executesql('insert routes (id_object) values (4)'); tx.executesql("select * routes", [], function (tx, result) { alert(result.rows.item(0)['id_object']) }, function (tx, error) {alert('Неудача');} )};
but doesn't working. added click event.
<button id = "click2">Добавить в БД</button> function querysuccess(tx, results) { $('#click2').click(addobject); function addobject(tt){ tt.executesql('insert routes (id_object) values (4)'); tt.executesql("select * routes", [], function (tt, result) { alert(result.rows.item(0)['id_object']) }, function (tt, error) {alert('Неудача');} ) };
why that?
the transaction tx
closed shortly after function querysuccess
returns. click
handler executed later, when doesn't have valid transaction.
you have create new transaction inside click
handler.
Comments
Post a Comment