首页 > 代码库 > Ajax 无刷新在注册用户名时的应用的代码

Ajax 无刷新在注册用户名时的应用的代码

var xmlHttp;  
uName() //用户名失去焦点时  
{  
 if(all.uname.=="")  
 {  
  all.l1.innerHTML="不能为空!";  
  setTimeout("close(1)",1500);  
  return;  
 }  
 else  
 {  
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  
  xmlHttp.onreadystatechange=deal; //回调函数  
  var url="aJax.aspx?user=‘"+all.uname.+"‘"; //将要跳转到检测用户名的页面  
  xmlHttp.open("get",url,true); //用 get 模式提交表单 到 url ;并启动 一步处理  
  xmlHttp.send(null); //发送  
 }  
}  
deal()  
{  
 //alert(xmlHttp.readystate+"__"+xmlHttp.status);  
 if(xmlHttp.readystate!=4)  
 {return; }  

 if(xmlHttp.status!=200)  //等于500 时是 sql 语句或数据库的错误  
 {return;}  
 //  

 var num = xmlHttp.responseText; //接收服务器发送的信息  
 //alert(num);  
 all.l1.innerText="";  
 if(num>0)  
 {  
  all.l1.innerText="次用户名已被使用!";  
 }  
 else   
 {  
  all.l1.innerText="√";  
 }  

}

 

<iframe id="google_ads_frame2" vspace="0" height="250" marginHeight="0" src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-3447371224873639&output=html&h=250&slotname=8660799060&adk=1970350646&w=300&lmt=1399459129&flash=0&url=http%3A%2F%2Fwww.cnblogs.com%2Franzige%2Fp%2F3713683.html&dt=1399459133226&shv=r20140501&cbv=r20140417&saldr=sb&prev_slotnames=4356862740&correlator=1399459133118&frm=20&ga_vid=429972749.1397695120&ga_sid=1399454383&ga_hid=1076977528&ga_fc=1&u_tz=480&u_his=148&u_java=1&u_h=768&u_w=1364&u_ah=740&u_aw=1364&u_cd=16&u_nplug=0&u_nmime=0&dff=tahoma&dfs=12&adx=0&ady=1234&biw=314&bih=74&eid=44901217%2C317150304&oid=3&rx=0&eae=0&docm=9&vis=0&fu=0&ifi=2&xpc=pXKFVlMRXn&p=http%3A//www.cnblogs.com&dtd=45" frameBorder="0" width="300" allowTransparency="true" name="google_ads_frame2" marginWidth="0" scrolling="no" hspace="0"></iframe><iframe id="google_ads_frame3" vspace="0" height="250" marginHeight="0" src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-3447371224873639&output=html&h=250&slotname=8660799060&adk=1970350646&w=300&lmt=1399459129&flash=0&url=http%3A%2F%2Fwww.cnblogs.com%2Franzige%2Fp%2F3713683.html&dt=1399459133279&shv=r20140501&cbv=r20140417&saldr=sb&prev_slotnames=4356862740%2C8660799060&correlator=1399459133118&frm=20&ga_vid=429972749.1397695120&ga_sid=1399454383&ga_hid=1076977528&ga_fc=1&u_tz=480&u_his=148&u_java=1&u_h=768&u_w=1364&u_ah=740&u_aw=1364&u_cd=16&u_nplug=0&u_nmime=0&dff=tahoma&dfs=12&adx=304&ady=1484&biw=314&bih=74&eid=44901217%2C317150304&oid=3&rx=0&eae=0&docm=9&vis=0&fu=0&ifi=3&xpc=Pp8UXFxAAb&p=http%3A//www.cnblogs.com&dtd=51" frameBorder="0" width="300" allowTransparency="true" name="google_ads_frame3" marginWidth="0" scrolling="no" hspace="0"></iframe>