js中ajax添加header中的token

js中ajax添加header中的token

getInterfaceData =function(){

var token = get_all_header();

token = eval('(' + token + ')').access_token;

$.ajax({

    type : "GET",

    url : Data_convention.interfaceData.url,

    data : {

        vcl_dictsys_id:"",

        vcl_dictvb_id:""

    },

    contentType: "application/json;charset=utf-8",

    dataType: "json",

    beforeSend: function (XMLHttpRequest){

        XMLHttpRequest.setRequestHeader("Authorization", "Bearer  "+token);

    },

    success : function(result) {

        if(result!=""&&result!=null){

        }else{

        }

    },

    "error" : function(result) {

        alert("获取失败!");

    }

});

}

你可能感兴趣的:(应用)