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

我正在使用IE8,我正在发送一个发送回应响应作为json的url的ajax请求.下面给出了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);
    }
  });
});

我确信服务器发送JSON响应,但IE8将其视为文件显示下载弹出框.但对于FF和Chrome,相同的过程可以正常工作.当我将json替换为dataType中的jsonp时,仍然会发生这种情况

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

我的json响应体也由一个带html标签的字符串组成.

任何想法为什么会发生这种情况?

谢谢

解决方法

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

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

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...