0x800a1391 – JavaScript runtime error: 'JSON' is undefined in IE 10-Collection of common programming errors

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?

Originally posted 2013-11-09 22:44:33.