blueimp jquery文件上传 - “完成”,“完成”回调不适用于IE 9 [英] blueimp jquery file upload - "done", "complete" callbacks not working for IE 9

查看:169
本文介绍了blueimp jquery文件上传 - “完成”,“完成”回调不适用于IE 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Blueimp Jquery File Upload 插件异步上传文件。它适用于大多数其他浏览器(有一些小问题) - 在IE上,我看到这个问题,完成,停止,总是,完成和一些其他事件回调没有被调用。

在调试时,我在完成,失败,总是中添加了console.logs,并在ajax请求中添加了一个complete _onSend函数(在jquery.fileupload.js) - 但他们似乎没有得到在IE中调用。

  _onSend:function(e,data){
var that = this,
jqXHR,
slot,
pipe,
options = that._getAJAXSettings(data),
send = function(resolve,args){
that._sending + = 1;
jqXHR = jqXHR || (
(resolve!== false&&
that._trigger('send',e,options)!== false&&
(that._chunkedUpload(options) || $ .ajax(options)))||
that._getXHRPromise(false,options.context,args)
).complete(function(result,textStatus,jqXHR){
console .log(complete);
))。done(function(result,textStatus,jqXHR){
console.log(done,result);
})。fail函数(jqXHR,textStatus,errorThrown){
console.log(fail,result);
})。always(function(a1,a2,a3){
console.log done,result);

}
});
return jqXHR;
};

为了便于阅读,插件代码被修剪了

我明白,在IE 9中,jquery.iframe-transport.js用于文件上传(因为XHR文件上传在IE中不支持)。

我不知道该如何解决这个问题。



谢谢!如果响应的内容类型设置为text / html或text / html,那么done事件被触发。简单(而不是应用程序/ JSON),当从服务器返回json。这仅适用于不支持XHR文件上传的浏览器(如IE9),以及blueimp插件使用IFrame传输的地方。



Content Negotiation在插件文档中:
https://github.com/blueimp/jQuery-File-Upload / wiki /安装程序


I am using Blueimp Jquery File Upload plugin to upload files asynchronously. It works well in most other browsers (with a few minor issues) - on IE, I see this issue that the "done", "stop", "always", "complete" and some other event callbacks are not getting invoked.

While debugging, I added console.logs in the "done", "fail", "always", and added a "complete" method to the ajax request in the _onSend function (in jquery.fileupload.js) - but none of them seem to get invoked in IE.

_onSend: function (e, data) {
        var that = this,
            jqXHR,
            slot,
            pipe,
            options = that._getAJAXSettings(data),
            send = function (resolve, args) {
                that._sending += 1;
                jqXHR = jqXHR || (
                    (resolve !== false &&
                    that._trigger('send', e, options) !== false &&
                    (that._chunkedUpload(options) || $.ajax(options))) ||
                    that._getXHRPromise(false, options.context, args)
                ).complete(function (result, textStatus, jqXHR) {
                    console.log("complete"); 
                }).done(function (result, textStatus, jqXHR) {
                    console.log("done", result); 
                }).fail(function (jqXHR, textStatus, errorThrown) {
                    console.log("fail", result); 
                }).always(function (a1, a2, a3) {
                    console.log("done", result); 

                   }
                });
                return jqXHR;
            };

[plugin code trimmed for readability]

I understand that in IE 9, jquery.iframe-transport.js used for the file upload (as XHR file uploads are not supported in IE).

I'm not sure how I should go about fixing/ debugging this issue.

Thanks!

解决方案

The done event gets fired if the content-type of the response is set to "text/html" or "text/plain" (instead of application/json) when json is being returned from the server. This applies only for browsers that do not support XHR file upload (such as IE9) and where the blueimp plugin is using IFrame transport instead.

Related info under "Content Negotiation" in the plugin documentation: https://github.com/blueimp/jQuery-File-Upload/wiki/Setup

这篇关于blueimp jquery文件上传 - “完成”,“完成”回调不适用于IE 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆