Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON is undefined in IE7 & IE6 #123

Open
ashokrkm opened this issue Mar 10, 2012 · 4 comments
Open

JSON is undefined in IE7 & IE6 #123

ashokrkm opened this issue Mar 10, 2012 · 4 comments

Comments

@ashokrkm
Copy link

The Hello World app out of box fails in IE7 with the error message, 'JSON' is undefined in line 3340. Screenshot here:

http://img210.imageshack.us/img210/7775/screenshot20120309at600.png

@stevenh512
Copy link

Older browsers like IE7 don't support JSON natively. If you want to support those browsers, there is a JSON parser written in Javascript here: https://github.com/douglascrockford/JSON-js

Just make sure you include that in your page before you include the Juggernaut js file or anything else that might require JSON.

@ashokrkm
Copy link
Author

thank you for the feedback. can you please tell what is the recommended way of doing this? is something like this a good idea:

<!--[if IE 7]>
<script type="text/javascript" src="json.js"></script>
<![endif]--> 

@stevenh512
Copy link

I would use json2.js from that repo instead of json.js, and probably just the script tag without the conditional comments.

<script type="text/javascript" src="json2.js"></script>

That way you support every browser that doesn't support JSON natively and not just IE7. If your browser already supports JSON, the code in json2.js gets out of the way and lets the browser handle it, so in a modern browser it won't hurt anything.

In fact, if you're using anything that concatenates and minifies your javascript and css assets for you, just add it like any other javascript asset. For example, in Jammit you would add it to your assets.yml and in Rails 3.1+ you would drop it in vendor/assets/javascripts and add an include in your application.js (before or after jquery, shouldn't matter, but definitely before everything else).

@liluo
Copy link

liluo commented Oct 9, 2012

@stevenh512 Cool, bugfix for IE6&IE7, thx~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants