后台代码:
[WebMethod]
public static string LoginTest(string userCode, string password)
{
UserManageCenterService service = new UserManageCenterService();
string msg = string.Empty;
service.AuthenticateUser(userCode, password, 10000, out msg);
if (msg == "验证成功")
{
string callBackURL = System.Configuration.ConfigurationManager.AppSettings["CallBackURL"].ToString();
msg = "{\"sign\":\"authenticated\",\"url\":" + ‘\"‘ + callBackURL + ‘\"‘ + "}";
return msg;
}
return msg;
}
前台代码:
$(document).ready(function () {
$("#btnlogin").click(function () {
if (CustomLogin() != false) {
$.ajax(
{
type: "POST",
contentType: "application/json",
url: "Login.aspx/LoginTest",
data: "{‘userCode‘: ‘" + $("#txtUserName").val() + "‘, ‘password‘:‘" + $("#txtPassword").val() + "‘}",
dataType: "json",
success: function (msg) {
ajaxobj = eval("(" + msg.d + ")");
if (ajaxobj.sign == "authenticated") {
window.location.href = ajaxobj.url;
}
else {
alert(msg.d);
}
}
});
}
});
});