【发布时间】:2018-08-21 02:28:33
【问题描述】:
我有一个通过 ajax 的提交函数,它通过 jQuery 从表单中获取值。有多个放置区,我需要在按下整个表单的提交按钮时抓取它们。
我可以像这样访问 dropzones 文件对象:
$('#foobar')[0].dropzone.getAcceptedFiles()[0]
这给了我这样的东西:
File
_removeLink: <a class="dz-remove" href="javascript:undefined;" data-dz-remove="">
accepted: true
dataURL: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopG…etc"
height: 545
lastModified: 1516739363000
lastModifiedDate: Date 2018-01-23T20:29:23.000Z
name: "foobar.jpg"
previewElement: <div class="dz-preview dz-image-preview">
previewTemplate: <div class="dz-preview dz-image-preview">
size: 45960
status: "queued"
type: "image/jpeg"
upload: Object { progress: 0, total: 45960, bytesSent: 0, … }
webkitRelativePath: ""
width: 550
__proto__: FilePrototype { name: Getter, lastModified: Getter, lastModifiedDate: Getter, …
当我尝试将其放入对象中以发送到服务器时,我收到错误:
var params = {
id: $('bla).val(),
dropzone_image: $('foobar')[0].dropzone.getAcceptedFiles()[0]
}
TypeError: 'click' called on an object that does not implement interface HTMLElement.
如何将此 dropzone 文件作为图像/文件附加到此处以发送到后端?
【问题讨论】:
标签: jquery ajax typeerror dropzone.js