Help: IE7 won’t load my JSON but IE8 will – Using a JSON Validator

Monday, March 8th, 2010 | Business | by

I just ran into this issue, and found surprisingly little documentation.  My JSON request wasn’t returning.  I was using the jQuery “getJSON” method to send the request out.  Nothing was coming back.

Here’s the code, pretty basic stuff:

$.getJSON(strSource, function(json){
// handle JSON here
alert(json.data)
}

The code worked perfectly in Chrome, Safari, Firefox and even IE8.  Internet Explorer is usually a problem when it comes to web pages, but I rarely expect IE7 to have issues (IE6 is usually the culprit).

In this case it turns out I had an extra “comma” at the end of the JSON data that didn’t belong.  Other browsers gracefully degraded, but IE7 wouldn’t let it go.

I’m not saying IE7 should have worked, it was a mistake with my code.

How do you find and fix issues like this?

Solution

Use a JSON validator.  Whenever you are having issues with JSON data (or the code that loads/manipulates that data), I frequently find the culprit is misformed JSON.

I use JSONLint to validate my JSON content.

So if you’re working with JSON, and are having issues with browsers working with the data appropriately, take a quick few seconds and validate your JSON.

Related Posts

Tags: , , , , , , , , , ,

2 Comments to Help: IE7 won’t load my JSON but IE8 will – Using a JSON Validator

Kyler IE8 Team
March 24, 2010

Have you checked out the Microsoft IE Dev forum? Its a good source to take IE coding problems:

http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/threads?ocid=ie8_sm_a

Kyler IE Outreach Team

Paolo Mulder
September 24, 2010

IE 7 have two major issues.
– Caching
– white space.

Disable caching :
$.ajaxSetup({ cache: false });

Remove white space :
before & after your <php tags.

Leave a comment

*


Please share, it makes me happy:

Subscribe to Email Alerts

Follow Me

Follow seangw on twitter

Archives

Categories

prestashop theme

virtuemart template