zoukankan      html  css  js  c++  java
  • 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"})');  //用户名不存在
    
  • 相关阅读:
    WPF基础篇之静态资源和动态资源
    15-Node-数据库
    15-Node
    12-Git
    总-S04-03 项目-大事件
    00-PHP难点
    08-PHP基础
    15-ES6
    16-Vue-webpack
    00-Web难点
  • 原文地址:https://www.cnblogs.com/mr-amazing/p/4643538.html
Copyright © 2011-2022 走看看