最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery-File-Upload not firing done callback in Internet Explorer (IE9) - Stack Overflow

programmeradmin6浏览0评论

i checked some questions regarding the same issue, blueimp jquery file upload - "done", "complete" callbacks not working for IE 9 , but even after putting my Content-Type as 'text/html' as the response the 'done' callback isn't being fired. Also as the jQuery-File-Upload says i need to have a redirect to get the uploaded file () after the upload is done, but that isn't also being done. Any help would be appreciated. Regards.

i checked some questions regarding the same issue, blueimp jquery file upload - "done", "complete" callbacks not working for IE 9 , but even after putting my Content-Type as 'text/html' as the response the 'done' callback isn't being fired. Also as the jQuery-File-Upload says i need to have a redirect to get the uploaded file (https://github.com/blueimp/jQuery-File-Upload/wiki/Cross-domain-uploads) after the upload is done, but that isn't also being done. Any help would be appreciated. Regards.

Share Improve this question edited May 23, 2017 at 12:25 CommunityBot 11 silver badge asked Oct 10, 2013 at 16:02 Ricardo BrazãoRicardo Brazão 3001 gold badge6 silver badges14 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 10

ok so i go it working.The problem was that in the fileuploader configuration i had

dataType: 'json'

but since IE9 uses the iframe it makes a html request, and the response has the Content-Type 'text/html'. With that configuration the fileuploader is expecting to receive a json response so my response was going to a fail callback i made just for testing. Got it working by looking at this post jQuery FileUpload doesn't trigger 'done'

The most voted answer isn't the best solution and can throw errors. Actually, setting dataType isn't recommended for IE < 10, from this (awesome) article:

When the dataType option is set to text, json, html, or script, the iframe transport performs some processing of the response. Because it is operating on a DOM object obtained from the iframe it uses, however, and not the raw HTTP response data, there is the potential for some surprises to pop up.

http://missioncriticallabs.com/blog/2012/04/lessons-learned-from-jquery-file-upload/

Real solution:

The "thing" about not firing in IE < 10 isn't related with dataType, is just the lack of callback add that forces the file push in fileupload event.

$('#file_file').fileupload({
    add: function (e, data) {
        data.submit(); //this will 'force' the submit in IE < 10
    },
    done: function (e, data) {
        alert('Done');
    }
});
发布评论

评论列表(0)

  1. 暂无评论