SCRIPT5009: 'JSON' is undefined

前端 未结 7 799
刺人心
刺人心 2020-12-14 14:39

I get the following error in IE 9 SCRIPT5009: \'JSON\' is undefined only when in compatability mode. the line causing this error is

JSON.string         


        
相关标签:
7条回答
  • 2020-12-14 15:15

    If you are using jQuery library at your page, than you could use $.parseJSON.

    0 讨论(0)
  • 2020-12-14 15:16

    JSON is not available in compatibility mode IE:

    Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards.

    Since you shouldn't be using (or worse, reyling on ) compatibility modes in the first place, you should switch IE to standards-mode by adding a valid doctype.

    0 讨论(0)
  • 2020-12-14 15:27

    I have done LOCAL Jquery added .NEt 2.0 code testing, it works fine without any problem. But after migrate the code to IIS v6 server then access from same IE browser, then problem appear "JSON" undefined. After read this recommendation, downlode the file json2.js and add below into source code.

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

    EVERYTHING WORKING Fine.

    Good Thank you.

    0 讨论(0)
  • 2020-12-14 15:30

    See here for a blog post explaining the situation: Resolve JSON is Undefined Error in Internet Explorer

    Include the JSON library in your page and you should be good to go.

    0 讨论(0)
  • 2020-12-14 15:34

    Yes, JSON is defined natively in modern browsers, but not in IE. You need to import a library. For example, http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js

    0 讨论(0)
  • 2020-12-14 15:36

    You need to include json2.js

    see json2 inclusion

    for more details. There are cases where we have to deal with cases where clients use IE7 standards. So our code had to cater to such cases too. Ours being a retail website is accessed by hundreds of clients who use IE7 standards. Including json2 solves this issue

    0 讨论(0)
提交回复
热议问题