Internet Explorer Error: SCRIPT5009: ‘JSON’ is undefined


You may notice that your jQuery application stops working without throwing any JavaScript error messages, but the same code works in Chrome and FireFox. There are a few reasons this could happen. First, you could be using an older version of IE (like 7) where JSON is not natively implemented and you have to force its inclusion. Second, your newer IE browser may be running in compatibility mode which is making it behave like IE7 and thus not including JSON natively.

Solution 1:

  • Setup your HTML so that the browser does not run in compatibility mode. This will ensure that the IE8/IE9 engine renders the page. The downside of this is that your page will still fail on IE7.

Solution 2:

  • Manually include the JSON library in your page. You can either include it with all page loads or specifically check what browser the user is using and only send it to browsers that need it.
  • The file that you want on the below link is “json2.js”. Newer browser should ignore this file if you include it, but it will allow older ones to work.
  • You can find the JSON library here:
    • If you included this in the same directory with your HTML you would just add this somewhere below your jQuery inclusion with a:
<script src="json2.js" type="text/javascript"></script>

My choice and recommendation is solution #2 which is what I’ve use whenever I’ve run into this issue.

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.