0x800a1391 - JavaScript runtime error: 'JSON' is undefined in IE 10

Rameez Ahmed Sayad picture Rameez Ahmed Sayad · Mar 12, 2013 · Viewed 25.1k times · Source

I'm using IE 10 Compatibility on Windows 8, I'm getting this error while running the WebApp in Debug mode(VS 2012). 0x800a1391 - JavaScript runtime error: 'JSON' is undefined Code below

var data = JSON.stringify(GetUserDetails());

function GetUserDetails() {
    var userData = {};
    userData.userName = $('#txtUserName').val();
    userData.password = $('#txtPassword').val();
    return userData;
}

Also , the strange fact is the same code hosted in IIS 8 runs fine in IE 10 Browser. Any inputs?

Answer

T.J. Crowder picture T.J. Crowder · Mar 12, 2013

IE8 and up only have the JSON object in standards mode. So you need to make sure the document has a doctype.