IE9上的jQuery ajax问题

Cri*_*riu 3 ajax asp.net-mvc jquery internet-explorer-9

我正在使用这个插件让用户通过ajax上传图像.

要创建上传器并触发帖子,请使用以下jQuery函数:

function createUploader() {
        var uploader = new qq.FileUploader({
             element: document.getElementById('file-uploader'),
             allowedExtensions: ['pdf'],
             multiple: false,
             action: '@Url.Action("AjaxUpload", "Upload")',
             onComplete: function(id, fileName, responseJSON){
               window.location.href = responseJSON.message;
            }
        });
    }
Run Code Online (Sandbox Code Playgroud)

好吧,responseJSON.message我正在返回文件上传的路径(实际转换),我正在做一个window.location.href强制浏览器显示该文件的用户DOWNLOAD框的技巧.

这适用于FF和Chrome,但在IE上它说:

Do you want to open or save AjaxUpload from localhost?

如果您按下打开,而不是从指定位置获取文件,您实际上会得到一个包含responseJSON消息的文件.

任何jQuery大师能给我一个线索来解决这个问题吗?

更新:我可以确认的是问题不window.location.href = responseJSON.message;在于因为即使我删除了这一行并且alert('something')发生了相同的问题...因此onComplete,IE尝试打开JSON响应而不是解析...

Ins*_*dBy 5

尝试

return Json(new { Data = new { message = outputFilePathResponse } }, "text/html");
Run Code Online (Sandbox Code Playgroud)

参考: IE尝试在ASP中下载JSON.NET MVC 3