I have an MVC 4 app containing a View with a form with several fieldsets. When I post this form in Chrome, it saves without error. In IE 10.0.92
I get an error in the following jQuery method. The line throwing the error has an arrow. This is roughly line 538. I've determined this method is not even called when executing in Chrome.
parseJSON: function (data) {
// Attempt to parse using the native JSON parser first
if (window.JSON && window.JSON.parse) {
--> return window.JSON.parse(data);
}
if (data === null) {
return data;
}
if (typeof data === "string") {
// Make sure leading/trailing whitespace is removed (IE can't handle it)
data = jQuery.trim(data);
if (data) {
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
if (rvalidchars.test(data.replace(rvalidescape, "@")
.replace(rvalidtokens, "]")
.replace(rvalidbraces, ""))) {
return (new Function("return " + data))();
}
}
}
jQuery.error("Invalid JSON: " + data);
},
The error I'm getting is the following:
I did an alert on the value of 'data', and I get an Undefined. I don't have a great deal of experience with jQuery or JavaScript. If more information is needed, I would be glad to provide it.
After some further testing, this change seems to fix the issue, but I'm not sure this is the right approach:
parseJSON: function (data) {
if (data === undefined) {
return data;
}
// Attempt to parse using the native JSON parser first
if (window.JSON && window.JSON.parse) {
return window.JSON.parse(data);
}
'{ "Users": [{ "key": "1", "label": "Tom Clancy" }, { "key": "12", "label": "Steve Martin" }] }'