I'm attempting to track down a javascript exception I'm getting when parsing some JSON in IE that has been returned by an AJAX request. Normally I'd assume a JSON formatting error somewhere in my code but in this case the JSON parses fine in Chrome, FireFox & IE but in IE's case ONLY if the URL is localhost. If I change the URL to my-laptop instead, which points to exactly the same location, the JSON fails to parse in IE but is still ok in Chrome and FireFox.
The JSON is very simple. The line below is from VS.Net's debugger so the double quotes on the ends are cosmetic:
data = "{ "ID" : 15, "Name" : "Hobart" } "
The JSON is being parsed with:
data = JSON.parse(data);
I've checked everything I can think of to see if the response is different between the response from localhost and my-laptop but can't spot anything. Why would IE decide not to parse the JSON when the server hostname changes?
Update: If I open up the localhost version with IE's compatibility mode switched on then the JSON paring alsi fails. Turn off compatibility mode and it works.