This code is working:
tx.executeSql('INSERT INTO Routes (id_object) VALUES (4)'); tx.executeSql( "SELECT * FROM Routes", [], function (tx, result) { alert(result.rows.item(0)['id_object']) }, function (tx, error) { alert('Неудача');} )};
If I hang the same code on the button, then it stops working?
<button id = "click2">Добавить в БД</button> $('#click2').click(function(){ tx.executeSql('INSERT INTO Routes (id_object) VALUES (4)'); tx.executeSql( "SELECT * FROM Routes", [], function (tx, result) { alert(result.rows.item(0)['id_object']) }, function (tx, error) { alert('Неудача');} ) });
Where is the mistake? help.
$(function() {})
? - zb '