Ajax,vs2010中正常,iis中不能运行!!!
ajax代码:
$.ajax({
url: "/Account/LogOnAjax/",
type: "POST",
data: {
UserName: c,
Password: d,
RememberMe: $("#ustate").attr("checked")
},
dataType: "json",
timeout: 6e4,
cache: false,
success: function (c) {
if (c.result) {
alert("111");
a.login_success(b, c.info);
}
else {
alert("222");
a.tipMsg_cont("账号或密码不太对吧! 重试一次?");
a.tipMsg_show(b);
a.elem_text_upawd.select();
a.login_submit_set({
is提交状态: false,
is提交按钮: true,
is对话框按钮: true,
is可点击链接: true
})
}
},
error: function (d, c) {
a.login_submit_set({
is提交状态: false,
is提交按钮: true,
is对话框按钮: true,
is可点击链接: true
});
switch (c) {
case "timeout":
a.tipMsg_cont('对不起!登录已超时,重新<a style="margin-left:3px; color:#369" href="javascript:void(0)" onclick="LKLog_Pawd.re_smt_login();">登录</a>');
a.tipMsg_show(b)
}
}
})
============================================================
AccountController中代码:
[HttpPost]
public JsonResult LogOnAjax(LogOnModel model)
{
//如果用户名与密码都不为空
if (ModelState.IsValid)
{
用户 userInfo = null;
/* 验证用户登录 */
int returnValue = MembershipService.ValidateUser(model.UserName, model.Password, out userInfo);
#region 处理返回值
/* 编号不存在 */
if (returnValue == 1)
{
return LKPageJsonResult.Failure("用户名不存在,请重新输入");
}
/* 密码错误 */
else if (returnValue == 2)
{
return LKPageJsonResult.Failure("密码错误,请重新输入");
}
else
{
//保存cookie
FormsService.SignIn(userInfo, model.RememberMe);
return LKPageJsonResult.Success(new { uname = userInfo.姓名, uemail = userInfo.邮箱, uguid = userInfo.ID });
}
#endregion
}
else
{
return LKPageJsonResult.Failure("请输入您的用户名或密码");
}
}