WebSQL:table 未在更改时创建 window.location
WebSQL:table not creating on changing window.location
我正在尝试在用户点击提交按钮时存储数据。
代码如下:
var db = openDatabase('CBDB', '1.0', 'mySpecialDatabaseThatWontWork',10*1024*1024);
db.transaction(function (nw) {
nw.executeSql('Drop TABLE user');
});
function db1(){
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS user(empid varchar(10))');
var x = $('#nameT').val();
console.log(x);
tx.executeSql('INSERT INTO user (empid) VALUES (?)', [x]);
});
window.location.assign("www/landing.html");
}
现在,如果我对 window.location 进行注释,那么代码就可以正常工作。但是当 window 被重定向到一个新页面时, table 不会被创建。
代码有问题吗?
试试这个:
tx.executeSql('INSERT INTO user (empid) VALUES (?)', [x], function red(){window.location.assign("www/landing.html");});
我正在尝试在用户点击提交按钮时存储数据。
代码如下:
var db = openDatabase('CBDB', '1.0', 'mySpecialDatabaseThatWontWork',10*1024*1024);
db.transaction(function (nw) {
nw.executeSql('Drop TABLE user');
});
function db1(){
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS user(empid varchar(10))');
var x = $('#nameT').val();
console.log(x);
tx.executeSql('INSERT INTO user (empid) VALUES (?)', [x]);
});
window.location.assign("www/landing.html");
}
现在,如果我对 window.location 进行注释,那么代码就可以正常工作。但是当 window 被重定向到一个新页面时, table 不会被创建。
代码有问题吗?
试试这个:
tx.executeSql('INSERT INTO user (empid) VALUES (?)', [x], function red(){window.location.assign("www/landing.html");});