[Original] ajax user registration function tutorial 2 ','
//
This tutorial is original on this site.
Author: www.drise.cn
Email: drise@163.com
QQ: 271728967
//
The first reg. php file above has been completed, so I will do the second step.
Var xmlHttp = false;
Function ajaxcreate () {// here is the creation of the xmlhttpt object
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 () {// the operation to be performed after the reg. php onblur () event is received,
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 = "<div id =\\\ 'phperblog _ showinfo_red \\\ '> <font color = red> verifying. Please wait... </font> </div> ";
}
If (xmlHttp. readyState = 4 ){
Document. getElementById ("divxm"). innerHTML = xmlHttp. responseText;
}
}