ajax传输header中加token

function fn(id) {
    $.ajax({
        url: 'http://*******/api/xxx',
        data: {
            id: id,
            xx: xx
        },
        beforeSend: function(request) {
            request.setRequestHeader("Authorization", token);
        },
        dataType: 'JSON',
        async: false,//请求是否异步,默认为异步
        type: 'GET',
        success: function (list) {
        },
        error: function () {
        }
    });
}

你可能感兴趣的:(HTML)