首页 > Web开发 > 详细

ajax 跨域

时间:2015-07-13 20:22:02      阅读:348      评论:0      收藏:0      [点我收藏+]
$.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"})‘);  //用户名不存在

 

ajax 跨域

原文:http://www.cnblogs.com/mr-amazing/p/4643538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!