IE8将json响应视为文件并尝试下载它

Gag*_*gan 15 jquery download internet-explorer-8

我正在使用IE8,我正在向url发送ajax请求,该请求以json的形式发回响应.下面给出了ajax设置的jquery代码:

$(document).ready(function(){
  $.ajax({
    url: url_string,
    dataType: "json",
    success: function(response){
      alert('all is well');
    },
    error: function(request, status, error){
      alert(request);
      alert(status);
      alert(error);
    }
  });
});
Run Code Online (Sandbox Code Playgroud)

我确信服务器正在发送JSON响应,但IE8将其视为文件并显示下载弹出框.但同样的过程适用于FF和Chrome.当我更换这仍然发生JSONJSONP的dataType

但它总是进入错误回调方法.

我的json响应主体也包含一个带有html标签的字符串.

知道为什么会这样吗?

谢谢

And*_*eas 10

我遇到了同样的问题并通过在所有IE请求的响应头中设置Content-type ="text/html"来修复它(而不是"application/json")

我还写了一篇关于它的博客文章,其中包含更多信息:http://blog.degree.no/2012/09/jquery-json-ie8ie9-treats-response-as-downloadable-file/