【问题标题】: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 ...
            });
        }
    };
    

    【讨论】:

      猜你喜欢
      • 2019-09-11
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-10
      • 2013-06-25
      • 1970-01-01
      相关资源
      最近更新 更多