controller:
$info=array('error'=>0,'msg'=>'');
if($user_info){
if($user_info['is_lock']){
$info['error']=1;
$info['msg']='该账户已被锁定';
$this->ajaxReturn($info);
}else{
session('uid',$user_info['u_id']);
cookie('uid',$user_info['u_id'],3600);
$this->ajaxReturn($info);
}
}
}else{
$info['error']=1;
$info['msg']='用户名或密码错误!'
$this->ajaxReturn($info);
}
ajax得到的是json对象
var data=eval('('+res+')');
if(data.error){
alert(data.msg);
}else{
window.location.href="{:U('Index/index')}";
}