62,046
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
$(function () {
$('#btnlogin').click(function () {
$.ajax({
type: "post", //客户端向服务器发送请求时采取的方式
contentType: "application/json", //指定客户端发送给服务器的内容的类型以及服务器返回给客户端内容的类型为json格式
url: "WebService1.asmx/ValidateUser", //指明客户端要向哪个页面里面的哪个方法发送请求
data: "{user:'" + $('#auth_email').val() + "',pass:'" + $('#auth_password').val() + "'}", //指定伴随发送的请求传递到服务器的参数
// data:$('#authentication').serialize(),
async:true,
success: function (result) {//客户端调用服务器端方法成功后执行的回调函数
if (result.d == "false") {
var alertbox = document.getElementById("alertmessage");
alertbox.style.display = "block";
alert("登录失败");
}
else if (result.d == "A") {
alert(result.d);
location.href = "http://www.baidu.com";
}
}
})
return false;
})
})
</script>
$.ajax({
cache: false,
type: "POST",
url: 'Data.ashx?action=logon&rand=' + Math.random(),
data: $('#frmLogon').serialize(),
dataType: 'json',
success: function (msg) {
switch ($.trim(msg)) {
case '1':
window.location.href = '/Default.aspx?rand=' + Math.random();
break;
case '2':
$("#errorMessage").html('验证码错误');
break;
case '8':
$("#errorMessage").html('该账号没有管理权限');
break;
case '9':
$("#errorMessage").html('账号已被禁用');
break;
default:
$("#errorMessage").html('账号或密码错误');
break;
}
},
error: function () {
$("#errorMessage").html('系统异常!请重新登录,或者稍候再试');
enableSaveModify();
}
});