Home >php教程 >php手册 >[原创]ajax 实现用户注册功能教程二

[原创]ajax 实现用户注册功能教程二

WBOY
WBOYOriginal
2016-06-13 10:13:071278browse

[原创]ajax 实现用户注册功能教程二','

//

本教程由本站原创,转载请注明来处

作者:www.drise.cn

邮箱:drise@163.com

QQ:271728967

//

上面第一个reg.php文件己经做好了,我就来做第二步

var xmlHttp = false;
function ajaxcreate(){//这里是创建xmlhttpt对像

try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {

try {
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (e2) {

  xmlHttp = false;
 }

 }


if (!xmlHttp && typeof XMLHttpRequest != \\\'undefined\\\') {


  xmlHttp = new XMLHttpRequest();


 }


if(!xmlHttp){alert(\\\'Create Xmlhttp Fail \\\');return false;}


}

function ajax(){//这里是接到reg.php onblur()事件后要进行的操作,

 ajaxcreate();

 var xmvalue=document.getElementById("xm").value;


 var url="/boke/blog/type.php?txt="+encodeURI(xmvalue);


 if (xmvalue== null || xmvalue.length>20 || xmvalue == "") return false;


 xmlHttp.open("POST",url,true); 


 xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");


 xmlHttp.send(xmvalue); 


 xmlHttp.onreadystatechange=returnstate; 


}


function returnstate(){


 if(xmlHttp.readyState != 4 ){


  document.getElementById("divxm").innerHTML="

正在验证中,请稍后...
";


 }

 if(xmlHttp.readyState == 4 ){


  document.getElementById("divxm").innerHTML=xmlHttp.responseText;


 }


}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn