【问题标题】:dropzone js use $.Ajax and not inbuilt functionsdropzone js 使用 $.Ajax 而不是内置函数
【发布时间】:2017-01-08 06:11:26
【问题描述】:

我打算使用 dropzone 并且我是新手,我正在阅读一些文档

我打算将 dropzone 用于 UI 并使用其他一些 API 上传到服务器,那么我如何告诉 dropzone 使用我的自定义方法并将成功或失败传递给 UI

我发现了一些其他有趣的帖子,比如thisenter link description here

【问题讨论】:

  • 在options init函数中我是这样做的,this.on("sending", function(file, xhr, formData){ debugger; saveFiletoServer(file, 'account'); //自定义方法});所以文件是根据需要保存的,但是我如何告诉 Dropzone 文件是成功的,它在 UI 中抛出了一个错误。

标签: dropzone.js


【解决方案1】:

您可以设置init()函数并等待响应:

Dropzone.options.dropzoneForm = {
    init: function () {
        this.on("complete", function (data) {
             var res = JSON.parse(data.xhr.responseText); 
             //use the request's statusCode anyway you want to
             if(data.xhr.status === 200)
             {
                //modify the UI
             }
        });
    }
    dictResponseError: "error message when failed"
};

HTTP Status Codes

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-05
    • 2017-06-10
    • 2018-01-29
    • 2019-09-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多