- 直接设置headers
$.ajax({
type : "get",
dataType : "json",
async:false,
url : base_path + "aa/getList",
header: { Accept: "application/json; charset=utf-8"},
success : function(result) {
},
error : function(jqXHR, textStatus) {
jqAjaxError(jqXHR, textStatus);
}
})
- beforeSend设置
$.ajax({
type : "get",
dataType : "json",
async:false,
url : base_path + "aa/getList",
beforeSend: function (xhr) {
xhr.setRequestHeader("sso_token", "sso_token");
},
success : function(result) {
},
error : function(jqXHR, textStatus) {
jqAjaxError(jqXHR, textStatus);
}
});