这是FORM表单<form name="form"  method="post" onsubmit="return userOpenLogin(form)" action="/?C=login"></form>
JS中:
 $.post(domain_name + '/?C=checkUserLoginAjax&user_password=' + user_password +'&user_name='+encodeURIComponent(user_name), function(data){
           if(data == 0){
               $("#texttishi").html('登录名或密码错误!');
                return false;
            }else{
                $("#texttishi").html('输入正确!');
            }
        });
这样一来,每次不管是输入正确还是错误他都会跳转到登录页。我现在想让错误的时候停留,可以吗?

解决方案 »

  1.   

    把return提前:if(data == 0){
      return false;
      $("#texttishi").html('登录名或密码错误!');
      }这样试试
      

  2.   

    正确了也不能跳转啊。因为你用了ajax了。
      

  3.   

    你既然用ajax提交请求,为什么还用form呢? form 里是有个action的。而你这个表单里是个submit的按钮吧?
    不知道你明白没有?呵呵,给你个例子<input type="text" name="name" id="name" />
    <input type="text" name="password" id="password" />
    <input type="button" value="登陆" onclick="return login()" />
    js中:
    function login()
    {
       $.post(domain_name + '/?C=checkUserLoginAjax&user_password=' + user_password +'&user_name='+encodeURIComponent(user_name), function(data){
       if(data == 0){
         $("#texttishi").html('登录名或密码错误!');
         return false;
       }else{
         $("#texttishi").html('输入正确!');
         return true;
       }
       });}
    写的是伪代码哈,具体是这个意思
      

  4.   

    问题是没看到
    userOpenLogin()
    这个函数的原形及这个原形是否有返回true或者flase