登录无刷新判断
window.onload=function(){
var btnAdd=$("btnSubmit");
btnAdd.onclick=function(){
check();
}
}
var name;
var pass;
function check(){
name=$("tbUserName").value;
pass=$("tbPassword").value;
if(name==""){
alert("please check the name");
return;
}
if(pass==""){
alert("please check the pass");
return;
}
var xmlStr="<login>";
xmlStr+="<name>"+escape(name)+"</name>";
xmlStr+="<pass>"+escape(pass)+"</pass>";
xmlStr+="</login>";
var url="Login.ashx";
var myAjax=new Ajax.Request(
url,
{
method:"post",
postBody:xmlStr,
onComplete:Login
}
);
}
function Login(xmlhttp){
var result=xmlhttp.responseText;
if(result!="true"){
alert("name or pass is not true!please reset the mes");
return;
}
setCookie("customerinfo", result, 1);
readcustomercookielog();
}
[color=#FF0000]一般处理文件[/color]
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
if (context.Request.InputStream != null)
{
XmlDocument doc = new XmlDocument();
doc.Load(context.Request.InputStream);
String result = "";
if (doc != null)
{
String username = context.Server.UrlDecode(doc.GetElementsByTagName("name")[0].InnerXml);
String userpass = context.Server.UrlDecode(doc.GetElementsByTagName("pass")[0].InnerXml);
if (username == "zhangsan" && userpass == "123")
{
result = "true";
}
else
{
result = "false";
}
}
else
{
result = "faile";
}
context.Response.Write(result);
context.Response.Flush();
}
}