Choose a location:
posted 8/11/2011 by Raghav Khunger
Recently while working with some JavaScript code, I encountered an error in IE7 "IE Microsoft JScript runtime error: 'JSON' is undefined" The error was coming at this line
var data=JSON.stringify(......) ;
I was getting this error only in IE7 and not in IE8 or IE9. Then I came to know that JSON.stringify was not the part of IE7. It is supported in IE versions greater than 7 i.e IE8, IE9 and other modern browsers support it. So what is the solution? Solution:Use Douglas Crockford's json2.js. According to that file it:
// Create a JSON object only if one does not already exist. We create the// methods in a closure to avoid creating global variables.
So it will not conflict with modern browsers which support the JSON object. And after using that file I was able to work with JSON object in IE7, IE8, IE9 and other non-ie browsers like FF and Chrome.
What kind of email newsletter would you prefer to receive from CodeAsp.Net? 18