[javascript] 'JSON' is undefined error in JavaScript in Internet Explorer

We are using jQuery in our application. We have used a jQuery plugin to implement JavaScript session.

It is working properly in Firefox and most Internet Explorer 8 browsers.

But in some Internet Explorer 8 browsers it does not work. It gives the following error.

Message: 'JSON' is undefined
Line: 6
Char: 3
Code: 0


Message: '$.namesession' is null or not an object
Line: 53
Char: 2
Code: 0

`

The version of Internet Explorer in both the cases is same.

But there were some differences in Internet Explorer settings like Use SSL3.0 and Enable Smart Screen filters check boxes in the Advanced tab in the Internet options were unchecked.

When we checked it, it started working. When we unchecked them it was still working.

What is the actual problem in IE8?

This question is related to javascript jquery json internet-explorer

The answer is


<!DOCTYPE html>

Otherwise IE8 is not acting right. Also you should use:

<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />

Change the content type to 'application/x-www-form-urlencoded'


I had this error 2 times. Each time it was solved by changing the ajax type. Either GET to POST or POST to GET.

$.ajax({
        type:'GET', // or 'POST'
        url: "file.cfm?action=get_table&varb=" + varb
    });

I had the very same problem recently. In my case on the top of a php script I had some code generationg obviously some extra output to the browser. Removal of empty lines (between ?> and html-tag ) and simple cleanup helped me out:

<?php 
include('../config.php');

//

ob_clean();
?>
<!DOCTYPE html>

Check for extra commas in your JSON response. If the last element of an array has a comma, this will break in IE


Please add json2.js in your project . i was faced the same issue i have fixed.

please use the link: https://raw.github.com/douglascrockford/JSON-js/master/json2.js and create new file json.js, copy the page and past into newly created file , and move that file into your web application.

I hope it will work.


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to jquery

How to make a variable accessible outside a function? Jquery assiging class to th in a table Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Getting all files in directory with ajax Bootstrap 4 multiselect dropdown Cross-Origin Read Blocking (CORB) bootstrap 4 file input doesn't show the file name Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource how to remove json object key and value.?

Examples related to json

Use NSInteger as array index Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) HTTP POST with Json on Body - Flutter/Dart Importing json file in TypeScript json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Angular 5 Service to read local .json file How to import JSON File into a TypeScript file? Use Async/Await with Axios in React.js Uncaught SyntaxError: Unexpected token u in JSON at position 0 how to remove json object key and value.?

Examples related to internet-explorer

Support for ES6 in Internet Explorer 11 The response content cannot be parsed because the Internet Explorer engine is not available, or Flexbox not working in Internet Explorer 11 IE and Edge fix for object-fit: cover; "Object doesn't support property or method 'find'" in IE How to make promises work in IE11 Angular 2 / 4 / 5 not working in IE11 Text in a flex container doesn't wrap in IE11 How can I detect Internet Explorer (IE) and Microsoft Edge using JavaScript? includes() not working in all browsers