var xml_http = null;
//修改密码
function updatepassword() {
var password1 = $("input[id='ipt_newpassword1']")[1].value;
var password2 = $("input[id='ipt_newpassword2']")[1].value;
if (password1 == "") {
alert("新密码不能为空!");
return false;
}
if (password2 == "") {
alert("确认新密码不能为空!");
return false;
}
if (password1 != password2) {
alert("两次输入密码不一致!");
return false;
}
var os = getOs();
if (os != "Firefox" && os != "Safari") {
xml_http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
xml_http = new XMLHttpRequest();
}
var content = "type=" + encodeURIComponent("updatepassword") + "&password=" + encodeURIComponent(password1);
xml_http.open("POST", "/Handler/UserHandler.ashx", true);
xml_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xml_http.onreadystatechange = UpdatePasswordChanged;
xml_http.send(content);
$($("table[id='table_updatepassword']")[1]).hide();
$($("table[id='table_update']")[1]).show();
return null;
}
//修改密码状态返回
function UpdatePasswordChanged() {
if (xml_http.readyState == 4) {
if (xml_http.status == 200) {
if (xml_http.responseText == "True") {
alert("密码修改成功!");
closewindown();
} else {
alert(xmlHttp.responseText);
}
}
}
}
function getOs() {
var OsObject = "";
if (navigator.userAgent.indexOf("MSIE") > 0) {
return "MSIE"; //IE浏览器
}
if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
return "Firefox"; //Firefox浏览器
}
if (isSafari = navigator.userAgent.indexOf("Safari") > 0) {
return "Safari"; //Safan浏览器
}
if (isCamino = navigator.userAgent.indexOf("Camino") > 0) {
return "Camino"; //Camino浏览器
}
if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) {
return "Gecko"; //Gecko浏览器
}
}
string username = SecurityHelper.RequestFormStr("username", context.Request);
string password = SecurityHelper.RequestFormStr("password", context.Request);
bool is_successful = UserBll.Instance.UserSignIn(username, password);
if (is_successful)
{
///存储用户信息缓存
CacheHelper.SetSessionValue(CacheHelper.USERINFO_CACHE, UserBll.Instance.LoadCurrentUserInfo(username, password));
}
context.Response.Write(is_successful.ToString());
Json
using System;using System.Web;using System.Web.Script.Serialization;using System.Collections.Generic;public class handler : IHttpHandler{ public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/javascript"; context.Response.Cache.SetNoStore ( ); string name = context.Request["name"]; SortedDictionary values = new SortedDictionary(); values.Add("message", string.IsNullOrEmpty(name) ? "无名氏" : string.Format("你好 {0}, {1}", name, DateTime.Now)); context.Response.Write(new JavaScriptSerializer().Serialize(values)); }