在JQuery Ajax获取请求中发送标头

时间:2015-12-06 08:18:08

标签: javascript jquery ajax

这是我的代码。

$.ajax(this.url, {
        type: "GET",
        //dataType: "json",
        beforeSend: function (xhr) {
            xhr.setRequestHeader("x-token", token)
        },
        success: function (data) {
            console.log(data);
        },
        error: function(){
            console.log('error');
        } 
    });

我无法通过该代码发送ajax请求。我也尝试听到:{“x-token”:token},代替beforeSend:但它也不适合我。

0 个答案:

没有答案
相关问题