ajax 跨域

$.getJSON("http://192.168.1.11/fenxiao/admin/member/index.html?callback=?", {
                    dosubmit:'登录',username:username,password:password
                },function(obj) {
                    alert(obj.status);
                    /**
                     -1:用户不存在
                     -2:密码错误
                     -4:登陆失败
                     -5:用户名为空
                     -6:密码为空
                     -7:验证码错误
                     **/
                    if(obj.status == -1){
                        error_notice('用户不存在!');
                    }else if(obj.status == -2){
                        error_notice('密码错误!');
                    }else if(obj.status > 0){
                        error_notice(obj.str);
                        location = "http://dixintong.25fz.com/admin/index/index.html";
                    }else{
                        error_notice(obj.str);
                    }
                })

 PHP的返回值要这种格式

$callback = $_GET['callback'];
//echo $callback.'('.json_encode(array('status'=>'-1')).')';
exit($callback.'({"status":"-1"})');  //用户名不存在
原文地址:https://www.cnblogs.com/mr-amazing/p/4643538.html