带参数的jquery ajax post
我需要使用JQuery的$ajax功能上传文件,除了上传文件外,我还想知道该文件上传到哪个文件夹/目录。我尝试了以下方法,但无效:带参数的jquery ajax post,jquery,ajax,post,Jquery,Ajax,Post,我需要使用JQuery的$ajax功能上传文件,除了上传文件外,我还想知道该文件上传到哪个文件夹/目录。我尝试了以下方法,但无效: data = new FormData() data.append('csv', fileData) $.ajax cache: false contentType:false processData: false type: 'POST' dataType: 'script' url: '/api/upl
data = new FormData()
data.append('csv', fileData)
$.ajax
cache: false
contentType:false
processData: false
type: 'POST'
dataType: 'script'
url: '/api/upload/'
params: ['test'] <-- folder/directory i want to upload to
data: data
complete: (res) =>
if not (res.status is 200)
console.log(res.responseText)
return false
else
return true
如何将额外的参数传递给ajax post?谢谢您可以将附加参数添加到formData
data = new FormData()
data.append('csv', fileData)
data.append('path', 'my/path')
在中没有名为
params
的选项尝试搜索更多信息,您会发现这很有用:
data = new FormData()
data.append('csv', fileData)
data.append('path', 'my/path')