1
我有一个MVC 4应用程序,其中包含一个带有多个字段集的窗体。当我在Chrome中发布此表单时,它可以毫无误差地保存。在IE 10.0.92
中,我在以下jQuery方法中遇到错误。抛出错误的行有一个箭头。这大致是538行。我确定这个方法在Chrome中执行时甚至没有调用。jQuery 1.9.1错误 - 与IE发生但不是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);
},
我得到的错误是:
我做了提醒。“数据”的价值,我也得到一个未定义的。我对jQuery或JavaScript没有太多的经验。如果需要更多信息,我会很乐意提供。
经过进一步的测试,这种变化似乎解决这个问题,但我不知道这是正确的做法:
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);
}
代码试图解析的JSON是什么? – 2013-04-08 00:40:26
这也发生在Opera中。或者,也许只有我们两个面对它! – hjpotter92 2013-04-08 00:41:18
IE 10.0.92。而且,我不知道我从客户端向服务器发送任何JSON。也许间接地完成了。 – 2013-04-08 00:41:50