表单的提交是下面的代码:
$('#submit').on('click', function (evt) {
var jsondata;
var username = $("#username").val();
var password = $("#password").val();
var type = isRegister ? 'register' : login;
if (type === 'register') {
var passconfirm = $("#password-repeat").val();
$.ajax({
url: "/sign/signup",
type: "post",
data: {
username: username,
password: password,
passconfirm: passconfirm
}
});
}
});
下面是跳转的逻辑代码:
UserModel.create(user)
.then(function(result) {
user = {
id: result,
username: username
};
req.session.user = user;
console.log(req.session.user);
req.flash('success', '注册成功');
res.redirect('/sign');
}).catch(function(e) {
if(e.message.match('ER_DUP_ENTRY')) {
req.flash('error', '用户名已被占用');
res.redirect('/sign');
}
});
可以看到拿到了值,但是我的页面跳转不过去,依然在第一个sign那里QAQ