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.

  • can wrap in $(function() {}) ? - zb '
  • one
    not understood. in the same place click costs. - Radik Kamalov
  • on a button a log on hang up, click fulfills? can you click on the wrong button - Gorets
  • test alert is triggered. - Radik Kamalov

0