【问题标题】:fileupload function done is not getting called文件上传功能完成没有被调用
【发布时间】:2019-09-12 00:57:20
【问题描述】:

长话短说,我想允许用户将文件上传到服务器。我正在尝试使用 Jquery 文件上传功能,但它似乎无法正常工作。

我已经简化了我的代码以查明错误/错误。我认为 done 例程没有被调用。

所以只有第一个 console.log("add executed") 会被打印出来。

<input type="file" id="files" name="files[]" />
<output id="list"></output>
$('#files').fileupload({
 dataType : 'json',
 add: function (e, data) {
   data.submit();
   console.log("add executed");
 },
 done: function (e, data) {
   console.log("done executed")
 }
});

控制台输出:“添加已执行”之后没有任何内容

【问题讨论】:

    标签: javascript jquery jquery-file-upload


    【解决方案1】:

    您需要提供一个 URL 并将文件实际上传到服务器,并且服务器需要发送响应(成功或错误)以便您调用“完成”回调。

    docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-14
      • 2013-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多