【问题标题】:How to get server response in dropzonejs [closed]如何在dropzonejs中获得服务器响应[关闭]
【发布时间】:2020-01-05 12:11:42
【问题描述】:
我正在使用 dropzonejs 上传图片。
我想在文件成功上传后得到服务器响应。
我怎样才能得到它?
【问题讨论】:
标签:
javascript
php
dropzone.js
【解决方案1】:
你可以试试这样的。
HTML 代码
<form id="myform" action="/youraction"></form>
JavaScript 代码
Dropzone.options.myform={
success: function(file, response){
//Here you can get your response.
console.log(response);
}
}
在成功方法中,您将获得最新上传的文件和服务器响应。
了解更多信息。 https://www.dropzonejs.com/
【解决方案2】:
你可以使用成功事件。
Dropzone.options.myDropzone = {
init: function() {
thisDropzone = this;
this.on("success", function(file, responseText) {
var responseText = file.id // or however you would point to your assigned file ID here;
console.log(responseText); // console should show the ID you pointed to
// do stuff with file.id ...
});
}
};