此代码正在运行。
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('Неудача');} )};
但这不起作用。我添加了点击事件。
<button id = "click2">Добавить в БД</button>
function querySuccess(tx, results)
{
$('#click2').click(addObject);
function addObject(tt){
tt.executeSql('INSERT INTO Routes (id_object) VALUES (4)');
tt.executeSql("SELECT * FROM Routes", [],
function (tt, result) { alert(result.rows.item(0)['id_object']) },
function (tt, error) {alert('Неудача');} )
};
这是为什么?