在if(status=="1")前方一个alert(status)来看看当前status的值,或许根本不是1,或者2呢。

解决方案 »

  1.   

    这是我的jsp页面
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBk">
    <title>ajax+struts</title>
    </head>
    <script type="text/javascript"  src="../js/checkName.js">        </script>
    <body>
    <form name="form1" method="post" action="www.sina.com.cn">
    <input name="username" type="text" maxlength="20" />
    <input type="password" name="password"  />
    <input type="submit" onclick="testName();"/>
    </form>
    </body>
    </html>
      

  2.   

    我也遇到这样的问题,很奇怪的是,当有alert()时候,返回就是正确的,如果没有,就返回一样的值,不管你怎么样操作,我怀疑是不是因为ajax异步,当在alert时候去执行指定的程序了,而没有alert时候就不去执行?希望高手指点
      

  3.   

    你的setData里面的两个条件都没执行到,你说这个方法会返回什么?
      

  4.   

    你的setData里面的两个条件都没执行到,你说这个方法会返回什么?
    为什么?为什么没有执行到?
      

  5.   

    改成mygia(www.gzcost.com)所说的xmlHttp.open("GET", url,false);
    就可以了~!为什么?能不能说下啊!
      

  6.   

    xmlHttp.open("GET", url,false);
    和xmlHttp.open("GET", url,true);
    有什么区别啊
      

  7.   

    用true也可以,但是你要在url后面加一个时间戳、
    url="/TestAjsax/CheckPower?username="+username+"&password="+password+"&timestamp="+当前时间
      

  8.   

    应该是浏览器对="/TestAjsax/CheckPower?username="+username+"&password="+password的返回进行了缓存,可以在响应中禁止浏览器缓存;=======如下为禁止缓存的方法=======
    1, 在jsp或者servlet中加入
    <%
    response.setHeader("Pragma","No-cache");
    response.setHeader("Cache-Control","no-cache");
    response.setDateHeader("Expires", 0);
    %>
    2, 在页面中使用HTML标记,如下面:
    <HEAD>
    <META http-equiv=Pragma content=no-cache>
    <META http-equiv=Cache-Control content=no-cache>
    <META http-equiv=Expires content=0>