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

删除回忆录丶 提交于 2019-12-01 04:00:29

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');
    }
});
Ricardo Brazão

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'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!