[Original] Ajax implementation of user registration function tutorial 2','
//
This tutorial is original from this site, please indicate the source when reprinting
Author: www.drise.cn
Email:drise@163.com
QQ:271728967
//
The first reg.php file above has been completed, I will do the second step
var xmlHttp = false;
function ajaxcreate(){//Here is the creation of 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(){//Here are the operations to be performed after receiving the reg.php onblur() event,
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;
}
}