六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 35|回复: 0

AJAX

[复制链接]

升级  26%

3

主题

3

主题

3

主题

童生

Rank: 1

积分
13
 楼主| 发表于 2013-1-23 02:54:36 | 显示全部楼层 |阅读模式
<script type="text/javascript">
         
            function check(){
                var account=document.loginForm.account.value
                var pwd=document.loginForm.password.value
            var xmlHttp;
            if (window.XMLHttpRequest){
            
               xmlHttp = new XMLHttpRequest();
            }else if (window.ActiveXObject){
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
              
              }
              xmlHttp.open("post","ajax.jsp?account="+account+"&password="+pwd,true);
            
              xmlHttp.onreadystatechange=function(){
              
              if(xmlHttp.readyState==4){
                xm.innerHTML=xmlHttp.responseText
                }else{
               
                xm.innerHTML="正在登录,请稍等..."
                }
              }            
             xmlHttp.send();
            
            
            }
            
               
  </script>
   <form name="loginForm">
    姓名<input type="text" name="account" ><BR>
   
    密码<input type="password" name="password"><BR>
   
    <input type="button" value="OK" >

</form>
<hr>
<span id="xm"></span>
</body>

ajax.jsp内容

<%
  String account= request.getParameter("account");
  String pwd= request.getParameter("password");
  if(account.equals(pwd)){
     out.println("登录成功");
  }
  else{
  out.println("登录失败");
  }

%>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表