IE下jquery 解析 json的问题
时间:2009-08-07
来源:互联网
各位帮我的看看我的json问题在哪里?
我使用以下方法获取json:
$.ajax( {
url : "XXXXXXXXXXXXXXX",
data : "root=" + root,
cache : false,
dataType : "json",
type: "GET",
error : function(re, st, err) {
.....
},
success :
function(data){........}}
显示页面我设置header为:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
服务器发送json时我将返回数据的contentType设置为:
application/json;charset=utf-8
以下是返回的JSON数据:
[ { "children" : [ { "hasChildren" : true,
"id" : "15",
"text" : "<a href='/store/security/product.action?filter_EQ_category=15'>clothes</a>" ,
},
{ "text" : "<a href='/store/security/product.action?filter_EQ_category=16'>machine</a>" },
{ "text" : "<a href='/store/security/product.action?filter_EQ_category=17'>sex</a>" }
],
"classes" : "important",
"expanded" : true,
"id" : "14",
"text" : "<a href='/store/security/product.action?filter_EQ_category=14'>product</a>"
} ]
该json在firefox和chrome下解析没问题.$.ajax都执行的是success中的function.但在ie8中$.ajax执行的是error中的function.
我把返回的json数据替换为简单:{"text","content"}后,ie解析良好.执行的是success中的function.
看来还是json的问题.
各位帮我看看我的json问题出在哪里.在ie下就出错.
我使用以下方法获取json:
$.ajax( {
url : "XXXXXXXXXXXXXXX",
data : "root=" + root,
cache : false,
dataType : "json",
type: "GET",
error : function(re, st, err) {
.....
},
success :
function(data){........}}
显示页面我设置header为:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
服务器发送json时我将返回数据的contentType设置为:
application/json;charset=utf-8
以下是返回的JSON数据:
[ { "children" : [ { "hasChildren" : true,
"id" : "15",
"text" : "<a href='/store/security/product.action?filter_EQ_category=15'>clothes</a>" ,
},
{ "text" : "<a href='/store/security/product.action?filter_EQ_category=16'>machine</a>" },
{ "text" : "<a href='/store/security/product.action?filter_EQ_category=17'>sex</a>" }
],
"classes" : "important",
"expanded" : true,
"id" : "14",
"text" : "<a href='/store/security/product.action?filter_EQ_category=14'>product</a>"
} ]
该json在firefox和chrome下解析没问题.$.ajax都执行的是success中的function.但在ie8中$.ajax执行的是error中的function.
我把返回的json数据替换为简单:{"text","content"}后,ie解析良好.执行的是success中的function.
看来还是json的问题.
各位帮我看看我的json问题出在哪里.在ie下就出错.
[ 此帖被ybak在2009-08-08 10:14重新编辑 ]
作者: ybak 发布时间: 2009-08-07
re, st, err
把后2个参数输出一下,看是什么错误
把后2个参数输出一下,看是什么错误
作者: keakon 发布时间: 2009-08-07
st 为"parseError"
err 为 undifined
err 为 undifined
作者: ybak 发布时间: 2009-08-07
type: "GET",=====>>type: "POST",
作者: tidelgl 发布时间: 2009-08-08
谢谢楼上的.我刚才试了下,这样不行.
我觉得这应该是json的问题.
和发送的请求的方式没有关系.
我在IE下调试的时候,
js会运行error里的function方法.
第一个参数httpRequest对象
里的responseText里面包含的String和我在服务器端发送的json是一至的.
可这段json在firefox下就没有问题
我觉得这应该是json的问题.
和发送的请求的方式没有关系.
我在IE下调试的时候,
js会运行error里的function方法.
第一个参数httpRequest对象
里的responseText里面包含的String和我在服务器端发送的json是一至的.
可这段json在firefox下就没有问题
作者: ybak 发布时间: 2009-08-08
问题找到了.是有行json后面居然多了个逗号

作者: ybak 发布时间: 2009-08-08
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28