悟性不高。。待指点只上关键些的代码。Login.htmlvar URL = '__URL__';
$.ajax({ //一个Ajax过程 
        type: "post", //以post方式与后台沟通 
        url : URL+'/checkLogin/', 
        dataType:'json',//从php返回的值以 JSON方式 解释 
        data: {username: $(".username").val(), password: $(".password").val(), verify: $(".inputer").val()},  
        async : false, //默认为true 异步 
        timeout: 3000, 
        success: function(data, str){
            $("<font color='red'>"+username+"</font>").appendTo("#result");
        }, 
        error: function(){
            alert("fail !!!");
        }
    });
<input type="text" name="username" class="username">
<input type="password" name="password" class="password">
<input type="text" name="verify" class="inputer">
<div id="result"></div>
LoginAction.class.php   class LoginAction extends Action {
public function index() {
            $this->display('Index:Login');
        }
public function checkLogin() {
$var = $_POST;
if(empty($_POST['username'])) {
    $this->ajaxReturn($var, '用户名必填', 0);//用户名
}else if(empty($_POST['password'])) {
    $this->ajaxReturn($var, '密码必填', 0);//用户名
}else if($_SESSION['verify'] != $_POST['verify']){
    $this->ajaxReturn($var, '验证码错误', 0);//验证码
}
}
}
错哪了?望大虾指教

解决方案 »

  1.   

    用firebug看看 请求的数据和返回的数据 方便调试!
      

  2.   

    没有form 表单啊
      

  3.   

    楼主表述清楚,出现什么错?
    加群中国php军团(7948162)
      

  4.   

    错在你用了 thinkphp 本身的一些 js
      

  5.   

     session里面保存的验证码是md5加密的。 
       具体报什么错你还是说清楚
      

  6.   

    你返回的json对象但是
    function 里面用username
    最好是把报的错误发一下