【发布时间】:2013-11-15 05:49:09
【问题描述】:
一旦发生异常,我会尝试终止上传。 “fileuploadchunkdone”事件处理程序允许我为每个块捕获从服务器发送的“错误”json。理想情况下,我想在发生异常时立即中止上传。我需要对每个块进行此检查,因为我需要记录错误并在发生异常时显示错误代码。但是,我无法通过调用 data.jqXHR.abort() 来终止异常。它只是继续遍历每个块。有任何想法吗?这是该事件处理程序的代码:
.on('fileuploadchunkdone', function (e, data) {
if (!data.result.success) {
running--;
var errMsg = "";
if (data.result != null) {
if (data.result.message != null) {
errMsg += data.result.message;
}
if (data.result.error != null)
errMsg += data.result.error;
}
layoutService.showErrorDialog(errMsg);
data.jqXHR = data.abort();
window.removeXHRfromPool(data);
if (running == 0) {
$('#dlgProgress').parent().hide();
$('#progresses').empty();
}
}
})
【问题讨论】:
-
这里有类似的问题。我试过在 chunksend 和 chunksuccess 事件中中止没有效果。还尝试在 setTimeout 中调用 abort,但这也无济于事。
标签: javascript jquery file-upload xmlhttprequest jqxhr