米脂
// 这个是全局的,所有的ajax请求都会加上这个请求头$(document).ajaxSend(function (event, xhr) {xhr.setRequestHeader("Content-Type", "application/json;charset=utf-8") ;xhr.setRequestHeader("Authorization", "Authorization") ;});//局部 第一种$('xxx').ajax({//...beforeSend:function(jqXHR,options){jqXHR.setRequestHeader("Content-Type", "application/json;charset=utf-8") ;jqXHR.setRequestHeader("Authorizationr", "Authorization") ;}//...}) ;//局部 第二种$('xxx').ajax({//...headers:{"Content-Type": "application/json;charset=utf-8","Authorizationr":"Authorizationr",}//...}) ;注意:修改请求头时,headers中的设置会覆盖beforeSend中的设置(意味着beforeSend先执行,所以被后面的headers覆盖)