$.each()遍历json
我已经得到了webservice返回的字符串:{"_bz":"","_czhm":"","_dhhm":"8401488","_dtbh":"","_gsclrq":"2...
我已经得到了webservice返回的字符串:{"_bz":"","_czhm":"","_dhhm":"8401488","_dtbh":"","_gsclrq":"2001-02-14","_gsxzbh":"01 “},{"_bz":"","_czhm":"","_dhhm":"8401488","_dtbh":"","_gsclrq":"2001-02-14","_gsxzbh":"01 ”}请问如何在jquery 的$each()中便利这两个对象啊!谢谢,我试了如下方式不行:
$(result).each(function(i) { alert(result.d[i]._dhhm); });
$.each(result.d,function(key,value)
{
alert(value._dhhm);
}); 展开
$(result).each(function(i) { alert(result.d[i]._dhhm); });
$.each(result.d,function(key,value)
{
alert(value._dhhm);
}); 展开
2个回答
展开全部
var value = [{"_bz":"","_czhm":"","_dhhm":"8401488","_dtbh":"","_gsclrq":"2001-02-14","_gsxzbh":"01"},{"_bz":"","_czhm":"","_dhhm":"8401488","_dtbh":"","_gsclrq":"2001-02-14","_gsxzbh":"01"}];
for(var key in value) {
for(var result in value[key]) {
alert("key: "+result+"; value: "+value[key][result]);
}
}
for(var key in value) {
for(var result in value[key]) {
alert("key: "+result+"; value: "+value[key][result]);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询