开发者

I'm getting an XML error messages for JSON?

UPDATE 2:

I did not mention that I do not get the error below in Chromium, but I do get it in IE8.

UPDATE 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

ORIGINAL QUESTION:

I have a serverside page which generates json data, which works perfectly well when accessed by jquery. However, when i navigate to the webpage which actually generates the json data, I get the following clientside error message in the browser:

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"}]

Why does that happen and how can I stop the error message fro开发者_JAVA百科m appearing?


Same problem here, context.Response.ContentType="text/plain"; made my day...


The error appears, because the JSON data is probably served as type text/xml and your browser tries to interpret the output as XML. If you served it as application/json that would probably not happen. Why would you want to directly access the page though?


Two tips here: 1) Install HttpFox Addon in Firefox which allows you to see exactly what is being sent/received 2) Install JSON View in Firefox which allows you to view JSON response in the browser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜