加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

自己修改的Ajax注册和登录验证

发布时间:2020-12-16 00:47:23 所属栏目:百科 来源:网络整理
导读:function getXMLHTTPRequest() { var xRequest=null; if (window.XMLHttpRequest) { xRequest=new XMLHttpRequest(); } else if (typeof ActiveXObject != "undefined") { xRequest=new ActiveXObject("Microsoft.XMLHTTP"); } return xRequest; } function

function getXMLHTTPRequest()
{
var xRequest=null;
if (window.XMLHttpRequest)
{
xRequest=new XMLHttpRequest();
}
else if (typeof ActiveXObject != "undefined")
{
xRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
return xRequest;
}
function Ajax(url)
{
AjaxObj = getXMLHTTPRequest();
AjaxObj.onreadystatechange = processRequest;
AjaxObj.open("get",url,true);
AjaxObj.setRequestHeader('Content-type','application/x-www-form-urlencoded');
AjaxObj.send(null);

}
function processRequest()
{
if(AjaxObj.readyState == 4)
{
if(AjaxObj.status == 200)
{
if(AjaxObj.responseText != "")
{
document.getElementById(reObj).innerHTML="";
document.getElementById(reObj).innerHTML=AjaxObj.responseText;
}
}
else
{
alert("您所请求的页面有异常。")
}
}
else
{
//document.getElementById(reObj).innerHTML="Loading......";
}
}

$(document).ready(function(){ $("#username").blur(function(){ var name=$("#username").val(); Ajax('reg.php?name='+name); reObj="check_user"; }); $("#email").blur(function(){ var mail=$("#email").val(); Ajax('reg.php?mail='+mail); reObj="check_mail"; }); $("#code").blur(function(){ var code=$("#code").val(); Ajax('reg.php?code='+code); reObj="check_code"; //reObj参数是回调函数中使用的参数 }); });

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读