错误:(索引):186未捕获语法错误:缩写属性初始值设定项无效



我在Django 中通过Ajax发送表单时遇到此错误

错误:(索引(:186未捕获语法错误:缩写属性初始值设定项无效

在线

data= formdata

你能帮我找出解决办法吗。

uploadBtn.addEventListener('click', e=>{
e.preventDefault()
progressBox.classList.toggle('not-visible', false)

var formdata = new FormData()
formdata.append('csrfmiddlewaretoken', csrftoken)
formdata.append('fileA', FileA.files[0])
formdata.append('a_year', year.value) 

$.ajax({
type: 'POST',
url: '',
enctype: 'multipart/form-data',
data = formdata,
success: function(response){
console.log(response)
},
error: function(response){
console.log(response)
},
cache: false,
contentType: false,
processData:false,
})     
})

您需要使用冒号而不是=

像这样:

data: formdata,

不是:

data = formdata, 

最新更新