我们有以下问题,我们确实需要在对象(uploadFile)中添加标题:我们无法接收它..
uploadFile: {
url: SERWER+"person/offer/photo/upload",
data: null,
type: 'POST',
enctype: 'multipart/form-data',
synchron: true,
headers : {
'X-Auth-Token' : localStorage.getItem('X-Auth-Token')
},
success: function(data, itemEl, listEl, boxEl, newInputEl, inputEl, id){
console.log(data);
它不起作用:(
答案 0 :(得分:1)
您无法向jQuery.filer添加标头。您可以尝试使用beforeSend
:
var beforeSendFn = function(){
jqXHR.setRequestHeader('X-Auth-Token', localStorage.getItem('X-Auth-Token'));
}
uploadFile: {
beforeSend: beforeSendFn
...
}