码迷,mamicode.com
首页 > Web开发 > 详细

简单的jQuery解析json数据

时间:2014-11-22 16:03:55      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:jquery解析json数据 jquer

<span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);">尊重劳动成果,转载请注明出处(http://blog.csdn.net/sllailcp/article/details/41113275)...</span>
以下是摘取部分json,jQuery需自己引入;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>


<script type="text/javascript">
$(function(){
var province_enum = [
    {id: 1, name: '北京', city: [
        {id: 1, name: '北京市', district: [
            {id: 1, name: '东城区'},
            {id: 2, name: '西城区'},
            {id: 3, name: '崇文区'},
            {id: 4, name: '宣武区'},
            {id: 5, name: '朝阳区'},
            {id: 6, name: '丰台区'},
            {id: 7, name: '石景山区'},
            {id: 8, name: '海淀区'},
            {id: 9, name: '门头沟区'},
            {id: 10, name: '房山区'},
            {id: 11, name: '通州区'},
            {id: 12, name: '顺义区'},
            {id: 13, name: '昌平区'},
            {id: 14, name: '大兴区'},
            {id: 15, name: '怀柔区'},
            {id: 16, name: '平谷区'},
            {id: 17, name: '密云县'},
            {id: 18, name: '延庆县'}
        ]}
    ]},
    {id: 2, name: '天津', city: [
        {id: 2, name: '天津市', district: [
            {id: 19, name: '和平区'},
            {id: 20, name: '河东区'},
            {id: 21, name: '河西区'},
            {id: 22, name: '南开区'},
            {id: 23, name: '河北区'},
            {id: 24, name: '红桥区'},
            {id: 25, name: '塘沽区'},
            {id: 26, name: '汉沽区'},
            {id: 27, name: '大港区'},
            {id: 28, name: '东丽区'},
            {id: 29, name: '西青区'},
            {id: 30, name: '津南区'},
            {id: 31, name: '北辰区'},
            {id: 32, name: '武清区'},
            {id: 33, name: '宝坻区'},
            {id: 34, name: '宁河县'},
            {id: 35, name: '静海县'},
            {id: 36, name: '蓟县'}
        ]}
    ]},
]
for(var x=0;x<province_enum.length;x++){
	document.write('省:'+'id:'+province_enum[x].id+','+'name:'+province_enum[x].name+'<br>')
	for(var y=0;y<province_enum[x].city.length;y++){
		document.write('市:'+'id:'+province_enum[x].city[y].id+','+'name:'+province_enum[x].city[y].name+'<br>')
		for(var z=0;z<province_enum[x].city[y].district.length;z++){
			document.write('区:'+'id:'+province_enum[x].city[y].district[z].id+','+'name:'+province_enum[x].city[y].district[z].name+'<br>')
		}
	}
}


   });
</script>
</head>


<body>

<pre name="code" class="html"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);"><a href="</span><span style="color: rgb(51, 51, 51); font-size: 14px; line-height: 26px; font-family: Arial; background-color: rgb(255, 255, 255);">http://blog.csdn.net/sllailcp/article/details/41113275</span><span style="color: rgb(51, 51, 51); font-size: 14px; line-height: 26px; font-family: Arial; background-color: rgb(255, 255, 255);">"></span><span style="color: rgb(51, 51, 51); font-size: 14px; line-height: 26px; font-family: Arial; background-color: rgb(255, 255, 255);">(</span><span style="color: rgb(51, 51, 51); font-size: 14px; line-height: 26px; font-family: Arial; background-color: rgb(255, 255, 255);">尊重劳动成果,转载请注明出处</span><span style="color: rgb(51, 51, 51); font-size: 14px; line-height: 26px; font-family: Arial; background-color: rgb(255, 255, 255);">)...</span><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px; background-color: rgb(255, 255, 255);"></a></span>
</body></html>


简单的jQuery解析json数据

标签:jquery解析json数据 jquer

原文地址:http://blog.csdn.net/sllailcp/article/details/41382503

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!