//声明XMLHttpRequest对象
var xmlHttp;
//检测用户名是否存在
function CheckName(userName)
{
createXMLHTTP();//创建XMLHttpRequest对象
var url="DisposeEvent.aspx?Name="+userName+"&Event=Check";
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=checkUserName;
xmlHttp.send(null);
}
function createXMLHTTP()
{
if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();//mozilla浏览器
}
else if(window.ActiveXObject)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");//IE老版本
}
catch(e)
{}
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");//IE新版本
}
catch(e)
{}
if(!xmlHttp)
{
window.alert("不能创建XMLHttpRequest对象实例!");
return false;
}
}
}
//执行检测用户名回调函数
function checkUserName()
{
if(xmlHttp.readyState==4)//判断对象状态
{
if(xmlHttp.status==200)//信息成功返回,开始处理信息
{
if(xmlHttp.responseText=="true")
{
document.getElementById("imgName").src="images/true.gif";
document.getElementById("imgName").style.visibility="visible";
//让注册按钮失效
document.getElementById("btnReg").disabled=false;
}
else
{
document.getElementById("imgName").src="images/false.gif";
document.getElementById("imgName").style.visibility="visible";
document.getElementById("btnReg").disabled=true;
}
}
}
}
//注册新用户
function regUser()
{
if(document.getElementById("userName").value=="")
{
alert("对不起,用户名不为空");
return false;
}
if(document.getElementById("userPwd").value=="")
{
alert("对不起,密码不为空");
return false;
}
var url="DisposeEvent.aspx?Name="+document.getElementById("userName").value+"&Pwd="+document.getElementById("userPwd").value+"&Event=Reg";
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=regUserInfo;
xmlHttp.send(null);
}
//注册用户回调函数
function regUserInfo()
{
if(xmlHttp.readyState==4)//判断对象状态
{
if(xmlHttp.status==200)//信息成功返回,开始处理信息
{
if(xmlHttp.responseText=="true")//获取的Response.Write("true");里面的文本
{
alert("恭喜,新用户注册成功!");
document.getElementById("userName").value="";
document.getElementById("userPwd").value="";
}
else
{
alert("对不起,注册失败!");
document.getElementById("userName").value="";
document.getElementById("userPwd").value="";
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
AJAXReg.rar (13个子文件)
AJAXReg
App_Code
Connection.cs 685B
User.cs 4KB
DisposeEvent.aspx 453B
CreateObject.js 3KB
DisposeEvent.aspx.cs 1KB
Web.config 2KB
DbName_log.ldf 1024KB
App_Data
Default.aspx 1KB
DbName.mdf 3MB
Default.aspx.cs 383B
images
true.gif 147B
Thumbs.db 4KB
false.gif 148B
共 13 条
- 1
资源评论
- zhengtai502013-02-25很实用学习了
- hwg052012-07-30该资源很好,解决了我的困惑!AJAX参数返回如何调用一直不明白,看了这个源码后终于解决了。
- 筱白兔2016-04-18资源不错 很好的分享
nattystyle
- 粉丝: 28
- 资源: 25
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功