JQGrid 4.0、jquery 1.5.2、MVC3 json 响应不再起作用
我有一个 ASP.NET MVC3 应用程序,它与 jquery 1.4.2 和 jqgrid 3.8 配合得很好。现在我想升级到 jquery 1.5.2 和 jqgrid 4.0,但突然我的网格都不起作用了。我得到的错误取决于我使用哪个浏览器进行调试。 在chrome中,我得到以下错误:
Uncaught SyntaxError: Unexpected token :
并且jquery中的指令发生错误
head.insertBefore( script, head.firstChild );
(其中script.innerText包含从服务器返回的json结果)
在firefox中,使用firebug我得到以下错误
error:invalid label
,然后它显示json
json结果我检索非常简单,并在 jsonLint 上验证正确的 json:
{
"page" : 1,
"total" : 0,
"records" : 4,
"rows" : [
{
"id" : "ip_524",
"cell" : ["C", "Indeling1", 524]
},
{
"id" : "ip_531",
"cell" : ["E", "fe", 531]
},
{
"id" : "ip_545",
"cell" : ["MAX", "1234567890123456789012345678901234567890", 545]
},
{
"id" : "ip_541",
"cell" : ["ER", "Indeling1", 541]
}]
}
jquery 的 ajaxsettings 设置为传统使用 jQuery.ajaxSettings.traditional = true;
jqgrid 的数据类型是 json
I have an ASP.NET MVC3 application which worked just fine with jquery 1.4.2 and jqgrid 3.8. Now I wanted to upgrade to jquery 1.5.2 and jqgrid 4.0, but suddenly none of my grids are working. The error I get depends on which browser I use to do debugging.
In chrome I get the following error :
Uncaught SyntaxError: Unexpected token :
and there error occurs in jquery on the instruction
head.insertBefore( script, head.firstChild );
(where script.innerText contains the json result returned from the server)
In firefox, with firebug I get the following
error:invalid label
and then it's showing the json
the json result I'm retrieving is quite simple and validates as correct json on jsonLint:
{
"page" : 1,
"total" : 0,
"records" : 4,
"rows" : [
{
"id" : "ip_524",
"cell" : ["C", "Indeling1", 524]
},
{
"id" : "ip_531",
"cell" : ["E", "fe", 531]
},
{
"id" : "ip_545",
"cell" : ["MAX", "1234567890123456789012345678901234567890", 545]
},
{
"id" : "ip_541",
"cell" : ["ER", "Indeling1", 541]
}]
}
ajaxsettings for jquery is set to traditional using
jQuery.ajaxSettings.traditional = true;
datatype for jqgrid is json
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 stackoverflow 上找到了答案(无效标签 - jQuery Ajax/Json 请求)
似乎将以下几行添加到 javascript 解决了问题:
I've found an answer on stackoverflow (Invalid Label - jQuery Ajax/Json request)
Seems the following lines added to the javascript solves the problem: