JQuery文件上载插件,Internet Explorer和IFrame传输

msh*_*t12 2 iframe jquery file-upload internet-explorer-9 knockout.js

我正在使用这个插件(只是基本版本),并利用所有简洁的功能进行更新,以使用我自己的UI(使用Knockout.js和Twitter Bootstrap).以下是上下文的一些代码片段:

    // The file is sent to an ASP.NET MVC Web Api service to do all the business logic/DB stuff
    uploadUrl = http://web.api.url/?apikey=key

    $("#fileUpload" + "@index").fileupload({
        headers: {
            'Authorization': "@Html.AccessToken()",
            'Accept': $.support.ajax ? "application/json" : "text/plain"
        },
        url: uploadUrl,
        add: function (e, data) {
            $.each(data.files, function (index, file) {
                // add to KO viewmodel
            });
            data.submit();
        },
        fail: function (e, data) {
            var error = data.errorThrown;
            var text = data.textStatus;
        },
        done: function (e, data) {
            // do some more viewmodel operations
        },
        progress: function (e, data) {
            var progressPercentage = parseInt(data.loaded / data.total * 100, 10);
            // update viewmodel
        }
    });
Run Code Online (Sandbox Code Playgroud)

所述#fileUpload<Index>元件是一个文件输入

这在Chrome,FF和Safari中效果很好但是(惊喜)不在IE中.当我尝试从我的文件输入中选择一个文件时,我得到一个非常奇怪的响应 - 浏览器打开一个下载对话框?!

Do you want to open or save ?apikey=key (61 bytes) from webapiserver?
Run Code Online (Sandbox Code Playgroud)

我尝试在我的fileupload事件监听器中使用IE的脚本调试器和断点,它甚至从未进入内部.我在研究中看到过各种帖子和文章,表明接受类型的应用程序/ json会搞砸IE,所以我在我的代码中有一个条件来尝试处理它.

有什么我想念的吗?

p11*_*00i 5

你的问题出在服务器端.

IE有点笨,他接受服务器提供的第一个内容类型,所以你总是需要记住,首先尝试用text/plain或回答text/html.

然而,在jQuery插件的FAQ中提到这一点.