jQuery文件上传插件 – 在IE <10中未触发的失败回调

我使用的是https://github.com/blueimp/jQuery-File-Upload

它在现代浏览器中使用XHR文件上传,在oldIEs中使用隐藏的iframe上传(8,9)。

文件validation失败时,服务器返回4xx状态代码(错误/失败)。

$('#fileupload').fileupload({ url: url, dataType: 'json', done: function (e, data) { console.log("done") }, fail: function (e, data) { console.log("fail") } }) 

但是在oldIE中,即使我发送4xx状态代码,也会调用完成回调。 有没有办法让它调用失败回调( https://github.com/blueimp/jQuery-File-Upload/wiki/Options#fail )并读取响应正文或状态代码?

我认为它可能需要使用隐藏的iframe上传文件的方法,但我找不到文档中的任何特定内容。

我应该查看常见问题

 // By default, the iFrame Transport handles all responses as success, // so we override the iFrame to JSON converter to handle error responses: $.ajaxSetup({ converters: { 'iframe json': function (iframe) { var result = iframe && $.parseJSON($(iframe[0].body).text()); if (result.error) { // Handling JSON responses with error property: // {"error": "Upload failed"} throw result.error; } return result; } } });