有一个登录表单,上面有一个登录按钮(不是服务器控件)。我想在使用数据库结帐后登录到 user.aspx。所以我创建了一个页面:getlogin.aspx,它将连接到数据库并检查用户名和密码。我将通过 $.ajax 调用此表单(我的意思是 getlogin.aspx),如下所示:
$('#btnLogin').click(function () {
var pass = $('#txtPassword').val();
var user = $('#txtUsername').val();
$.ajax({
type: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: 'get/login.aspx',
data: { un: user, pa: pass },
beforeSend: function () {
$('#loader_login').addClass('loader_ajax');
},
success: function (jsonMsg) {
var result = jsonMsg.loggedIn;
if (result == "false") {
//show err dialog
}
else {
//redirect to user page with username as query string
window.open(location.host + "/" + "User.aspx?user=" + user);
}
},
complete: function () {
$('#loader_login').removeClass('loader_ajax');
}
});
});
所以在成功功能中:
success: function (jsonMsg) {
var result = jsonMsg.loggedIn;
if (result == "false") {
//show err dialog
}
else {
//redirect to user page with username as query string
window.open(location.host + "/" + "User.aspx?user=" + user);
}
我要去检查结果。一切都在正确的地方,但 window.open 根本不起作用!我该如何解决?