When jQuery callbacks don’t appear to work in IE7

I recently encountered a frustrating issue where a callback function from a jQuery .get() call was not being fired in IE7 but was working in other browsers including IE8.  I had a hunch that it was related to the data object being used to transport the returned JSON but wasn’t sure how.

After hitting my head against a brick wall and following through a number of dead-end forum thread’s, I worked it out the old fashioned way, which is why I thought I’d write up my findings in this short article.

I was making a request using the .get() jQuery function that was returning JSON, which was perfectly valid (I checked with JSONLint.com). However, upon checking the JSON that was being returned when using the awesome Chrome Developer Tools, I saw a nicely formatted JSON string in the response content… and that was the problem – it was a nice human readable structure… IE7 doesn’t like that!

Removing all redundant whitespace on the server side when forming my JSON string resolved my issue and my callbacks were once again being called within IE7 along with all other browsers.

Leave a comment if you have any questions.

Leave a Reply

Your email address will not be published. Required fields are marked *