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

Popular posts from this blog

How can I fetch data from a web server in an android application? -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -

jquery - How can I dynamically add a browser tab? -