日期:2014-05-16  浏览次数:20819 次

【求助】看看这段代码有啥错误
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<html>
  <head>  
  <title>页面无刷新登录</title>
  <script type="text/javascript">
  
  var xmlHttp;
  function createXmlHttp(){
  try{
  xmlHttp=new XMLHttpRequest();
  }catch(e){
  try{
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"):
  }catch(e){
  try{
  xmlHttp=new ActiveObject("Microsoft.XMLHTTP");
  }catch(e){
  alert("浏览器不支持Ajax!");
  }
  }
  }
  }
  }
   
  var name;
  var pwd;
  function check(){
  name=document.getElementById("uname").value;
  pwd=document.getElementById("upwd").value;
  if(name.length==0){
  document.getElementById("showName").innerHTML="用户名不能为空!";
  return false;
  }if(pwd.length==0){
  document.getElementById("showPwd").innerHTML="密码不能为空!";
  return false;
  }
  return true;
  }

  function doAjax(){
  createXmlHttp();
  if(xmlHttp!=null){
  if(check()){
  xmlHttp.open("post","<%=request.getContextPath() %>/login?uname="+name+"&upwd="+pwd,true);
  xmlHttp.setRequestHeader("Content-type","appliation/x-www-form-urlencoded");
  xmlHttp.onreadystatechange=processchange;
  xmlHttp.send(null);
  }
  }
  }
   
  function processchange(){
  if(xmlHttp.readyState == 4){
  if (xmlHttp.status == 200) {
  var mes=xmlHttp.reponseText;
  if (mes == "Y") {
document.getElementById("login").innerHTML = "欢迎!";
} else {
document.getElementById("login").innerHTML = "失败!";
}
  }
  }
  }
  </script>
  </head>
  
  <body>
  <div id="login">
  <table>
  <tr>
  <td>用户名:</td>
  <td><input type="text" id="uname" name="uname" /></td>
  <td id="showName"></td>
  </tr>
  <tr>
  <td>密码:</td>
  <td><input type="password" id="upwd" name="upwd"/></td>
  <td id="showPwd"><br></td>
  </tr>
  <tr>
  <td><input type="button" value="登录" onclick="doAjax()"/></td>
  </tr>
  </table>
  </div>
  </body>
</html>


------解决方案--------------------
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"):
这句应该是分号;
------解决方案--------------------
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"):
这个地方是个错误,你那里没有报错吗?
------解决方案--------------------
JScript co