您的位置:首页 > 其它

ajax 跨域

2015-07-13 17:58 375 查看
$.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"})');  //用户名不存在
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: