我收到JSON的XML错误消息?

时间:2011-05-20 10:16:36

标签: jquery asp.net xml vb.net json

更新2:

我没有提到我在Chromium中没有得到以下错误,但我确实在IE8中得到了它。

更新1:

Response Headers:
HTTP/1.1 200 OK
Date: Fri, 20 May 2011 15:40:23 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: application/json; charset=utf-8
Content-Length: 85

原始问题:

我有一个生成json数据的服务器端页面,在jquery访问时效果非常好。但是,当我导航到实际生成json数据的网页时,我在浏览器中收到以下客户端错误消息:

The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource 'http://companyname.com/json/data.aspx?id=7

[{"key":7,"value":"Default"}]

为什么会发生这种情况?如何阻止错误消息显示?

3 个答案:

答案 0 :(得分:4)

同样的问题,context.Response.ContentType="text/plain"; 让我的一天......

答案 1 :(得分:0)

出现错误,因为JSON数据可能是text / xml类型,浏览器尝试将输出解释为XML。如果你作为application / json服务它可能不会发生。你为什么要直接访问该页面?

答案 2 :(得分:0)

这里有两个提示: 1)在Firefox中安装HttpFox Addon,可以让您准确查看正在发送/接收的内容 2)在Firefox中安装JSON View,允许您在浏览器中查看JSON响应。