jQuery-File-Upload,失败事件在连接丢失时触发两次

时间:2014-03-27 12:42:02

标签: ajax xmlhttprequest jquery-file-upload

考虑以下代码......

var i = 0;

_$uploadWidget.on('fileuploadadd', function (e, data) {
    i++;

    console.log('Add file to queue with index: ' i);

    data.index = i;
    data.submit();
});

_$uploadWidget.on('fileuploadfail', function (e, data) { 
    console.log('File failed with index: ' + data.index);
});

通过$control.fileupload('add', {files: 'file[]'})向上传控件添加3个文件将触发fileuploadadd()个事件3次。如果服务器返回500,则fileuploadfail()事件会按预期触发3次,您将看到..

Add file to queue with index: 1
Add file to queue with index: 2
Add file to queue with index: 3
File failed with index: 1
File failed with index: 2
File failed with index: 3

但是,如果互联网连接丢失,则每个请求都会针对fileuploadfail()事件触发两次。

Add file to queue with index: 1
Add file to queue with index: 2
Add file to queue with index: 3
File failed with index: 1
File failed with index: 2
File failed with index: 3
File failed with index: 1
File failed with index: 2
File failed with index: 3

我非常确定只有在POST被解雇之前连接丢失才会触发第二个失败事件。

有人可以确认jQuery-File-Upload控件是否正在处理排队上传的重试?如果没有,那是什么?无论什么是负责任的,它可以被关闭吗?

注意:我使用jQuery-File-Upload版本5.40.1和jQuery 1.11.0

0 个答案:

没有答案