用户操作
[即时聊天] [发私信] [加为好友]
施凯ID:schuy
39次访问,排名2万外好友0人,关注者0
热爱编程!
schuy的文章
原创 1 篇
翻译 0 篇
转载 0 篇
评论 0 篇
最近评论
文章分类
    收藏
      相册
      存档
      软件项目交易
      订阅我的博客
      XML聚合  FeedSky
      订阅到鲜果
      订阅到Google
      订阅到抓虾
      订阅到BlogLines
      订阅到Yahoo
      订阅到GouGou
      订阅到飞鸽
      订阅到Rojo
      订阅到newsgator
      订阅到netvibes

      原创 急》》用AJAX验证用户唯一性的问题收藏

       | 

      我写了一段代码是进行用户名唯一性验证的,但是好像有些问题源码如下:

      >>>>>>>>Login.jsp页面的源码:

      <script language="javascript">
      var http_request=false;

      function send_request(url){  //初始化,指定处理函数,发送请求的函数
         http_request=false;
         //开始初始化XMLHttpRequest对象
         if(window.XMLHttpRequest){  //Mozilla 浏览器
           http_request= new XMLHttpReqeust();
        if(http_request.overrideMimeType){ //设置MiME类别
           http_request.overrideMimeType("text/html");
        }
         }
         else if(window.ActiveXObject){  //IE浏览器
            try{
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
         }catch(e){
           try{
         http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(e){}
         }
         }
         if(!http_request){  //异常,创建对象实例失败
            window.alert("不能创建XMLHttpRequest对象实例!");
         return false;
         }
         http_reqeust.onreadystatechange =processRequest;
         http_request.open("GET",url,true);     

      http_request.send(null);
      }
        function processRequest(){
          if(http_request.readyState == 4){  

           if(http_request.status == 200){ 

        alert(http_request.statusText);  //服务器返回的状态文本信息
        alert(http_request.responseText);   //服务器进程返回数据的文本版本
        }else{ //页面信息不正确
          alert("您所请求的页面有异常!!");
        }  
       }
       }

        function userCheck(){
           var f= document.form1;
        var username=f.username.value;
        if(username==""){
          window.alert("用户名不能为空.");
          f.username.focus();  //focus()是聚焦函数
          return false;
        }else{
        send_request('User_Test.jsp?username='+username);
        }
        }
      </script>

      <tr>
           <td>用户名:</td>
           <td><input type="text" name="username" value=""></td>
           <td><input type="button" name="check" value="唯一性检查" onClick="userCheck()"/></td>
      </tr>

      >>>>>>>User.jsp页面:

        <body>
        <%
          String username=request.getParameter("username");
          out.println(username);
          if("schuy".equals(username)){out.println();}
          else {out.println("该用户名可以使用!");}
        %>
        </body>

      问题是点击“唯一性检查”按钮后没有反应了!下面状态栏说script Error!但不知道那的错!本人才学AJAX!请各位高手帮忙看看!谢谢啦!

      发表于 @ 2008年05月20日 17:20:24|评论(loading...)|编辑

       | 

      评论:没有评论。

      发表评论  


      当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
      Csdn Blog version 3.1a
      Copyright © schuy