【发布时间】:2010-06-17 23:50:26
【问题描述】:
我有一个用于编写 JSON 的 ASPX 页面。它在 Firefox 和 Chrome 中运行良好,但是当我尝试在 IE 8 中使用它时,它给了我一个“无法显示 XML 页面”错误,而不是允许 jQuery 加载响应写入的 JSON。
有什么想法吗?
我的代码如下所示:
protected override void OnLoad(EventArgs e) {
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/json";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(string.Format("[ {{ \"Foo\": \"{0}\", \"bar\": \"{1}\" }} ]", "Foo Content", "Bar Content"));
Response.End();
}
【问题讨论】:
-
见下文:IE8 不喜欢将内容类型设置为“application/json”……愚蠢的 IE!
标签: javascript jquery asp.net json