Internet Explorer 8 Json Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the json is undefined ie9 company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Json Is Undefined Ie 11
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million json is undefined ie8 fix programmers, just like you, helping each other. Join them; it only takes a minute: Sign up JSON object undefined in Internet Explorer 8 up vote 61 down vote favorite 22 Currently I'm writing a JavaScript file json is undefined ie7 and have the following line: var res = "JSON=" + JSON.stringify(result); result is being set just above this line. The issue I'm having is that IE8 (IE8 only, that is) is reporting to me that JSON is undefined somehow. I'm not sure what to make of this since, as I understood it, IE8 is a browser that implemented JSON support. Does anyone have any idea what might be going on? javascript html json
How To Fix Json Is Undefined Error
internet-explorer-8 share|improve this question edited Mar 2 '15 at 17:38 Mark Amery 24.1k12119149 asked Jan 17 '11 at 16:23 keybored 1,99183261 4 Are you in compatibility mode? –SLaks Jan 17 '11 at 16:25 add a comment| 8 Answers 8 active oldest votes up vote 110 down vote accepted Make sure you're actually in IE 8 mode by using the preferred method, a standards doctype... ...or the undesired method, the X-UA-Compatible meta tag/header... See Defining Document Compatibility for more information. share|improve this answer edited Dec 12 '12 at 11:18 answered Jan 17 '11 at 16:26 Andy Earnshaw 201k49356372 9 Definitely worth checking this, because compat mode can be triggered without you necessarily realising it - open the Developer Tools (F12) and look in the toolbar for the browser mode. –Spudley Jan 17 '11 at 16:31 2 I dropped this line in and checked the dev tools. Definitely running in IE8 Standards Mode. –keybored Jan 17 '11 at 16:46 @keybored: something must be overriding the JSON global object then. Check your code for variations of JSON = (the example code you wrote in the question is a good start - are you using eval?). –Andy Earnshaw Jan 17 '11 at 18:19 I haven't seen anything like
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers ie8 json parse or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x javascript runtime error: 'json' is undefined Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Download Json2
only takes a minute: Sign up IE8 native JSON.parse bug causes stack overflow up vote 30 down vote favorite 15 TL;DR: Adding any non-built-in functions to Array.prototype AND Function.prototype will cause the IE8 native JSON parser to get a stack http://stackoverflow.com/questions/4715373/json-object-undefined-in-internet-explorer-8 overflow when parsing any JSON that contains an array, but only when you also pass a reviver function into JSON.parse(). This started out as a question, but I answered my own original question, so now I'll ask: can anyone think of a work-around for this IE8 bug that doesn't involve eliminating all JS libraries that modify Array.prototype and Function.prototype? Original question: I have about 13k of JSON data to parse. The structure of the data is an object with a http://stackoverflow.com/questions/1288962/ie8-native-json-parse-bug-causes-stack-overflow single value that is a nested array. { 'value':[[ stuff ], [ more stuff], [ etc ]] } I'm using json2.js, which defers to the browser native JSON.parse when available. I'm passing a reviver function into JSON.parse to handle dates properly. When IE8 is in IE7 emulation mode (which causes it to use the script-based json2.js parser) everything works fine. When IE8 is in IE8 mode (which causes it to use the browser-native JSON parser) it blows up with an "out of stack space" error. Firefox and Chrome, of course, work just fine with their browser-native JSON parsers. I've narrowed it down to this: if I pass even a do-nothing reviver function into JSON.parse, the IE8 native parser gets the stack overflow. If I pass in no reviver function, the IE8 native parser works fine, except it doesn't parse dates correctly. // no error: JSON.parse(stuff); // "out of stack space" error: JSON.parse(stuff, function(key, val) { return val; }); I'm going to play with my JSON data, to see if less data or less nesting of the data can avoid the error, but I was wondering if anyone had seen this before, or had any other suggested work-arounds. IE8 is slow enough already, it would be a shame to disable native JSON for that browser because of this bug. UPDATE: In other cases, with different JSON data, I'm getting a javascript error "$lineinfo is undefined" when I use the
by older browsers that have not implemented the JSON object. The solution to this error is to download the json2 library and include it in your script, as shown below: The application http://www.devcurry.com/2010/12/resolve-json-is-undefined-error-in.html uses the json2.js library for browsers that haven't implemented the JSON object yet. https://support.microsoft.com/en-us/kb/976662 After adding the json2.js library, you can now test the application on IE7 and you will get the desired output Note: All the latest browsers like Firefox 3.5+, IE 8+, Chrome, Safari 4+ etc. have built-in JSON capability. You also want to look at Is my JSON valid? Will you give this article a +1 is undefined ? Thanks in advance About The Author Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. json is undefined and The Absolutely Awesome jQuery CookBookFollow him on twitter @suprotimagarwal Posted by Suprotim Agarwal 15 comments: Anonymous said... I get this error on IE8 also. January 17, 2011 at 7:53 AM Suprotim Agarwal said... That could be as you are running IE8 in compatibility mode? January 17, 2011 at 9:00 PM Lucho said... Thanks a lot man. It really helped me out. Many thanks from Argentina =) Have a good day! bye. January 18, 2011 at 7:54 PM Anonymous said... Perfect one..Thanks a lot.. March 17, 2011 at 10:19 AM wildkaz said... Awesome man. You saved my life. Thanks (*follow*) July 19, 2011 at 7:23 AM Srinivasan said... Its really cooll man. September 22, 2011 at 1:34 AM balaram said... thanks it works for me perfectly December 11, 2011 at 9:22 PM mjwouda said... Excellent! Finally I get the Google Maps API in IE7 working! Thanks for sharing. February 16, 2012 at 6:01 AM Anonymous said... Oh man. Thanks for this help. You saved my week May 9, 2012 at 10:30 AM Anonymous said... Thank you! You solved my problem! June 19, 2012 at 4:19 AM Anonymous said... Thanks alot man...it saved my life. August 20, 2013 at 4:29 AM Anonymous sai
360 games PC games Windows games Windows phone games Entertainment All Entertainment Movies & TV Music Business & Education Business Students & educators Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft