json对象
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>数据获取测试页</title> <script type="text/javascript" src="plugin/jquery/jquery-1.8.3.js"></script> <script type="text/javascript" src="plugin/JUI/jquery-ui-1.10.3.custom.js"></script> <script type="text/javascript" src="plugin/table/yfTable.js"></script> <script type="text/javascript" src="plugin/Page/jquery.pagination.js"></script> <script type="text/javascript" src="js/common/common.js"></script> <script type="text/javascript" src="js/data/dataSource.js"></script> <script type="text/javascript" src="js/data/Sk.js"></script> <script type="text/javascript" src="js/data/Net.js"></script> <script type="text/javascript" src="js/data/Json.js"></script> <script> var data=" { root: [ {name:'1',value:'0'}, {name:'6101',value:'北京市'}, {name:'6102',value:'天津市'}, {name:'6103',value:'上海市'}, {name:'6104',value:'重庆市'},{name:'6105',value:'渭南市'}, {name:'6106',value:'延安市'}, {name:'6107',value:'汉中市'}, {name:'6108',value:'榆林市'}, {name:'6109',value:'安康市'}, {name:'6110',value:'商洛市'} ]}"; var dataObj=eval("("+data+")"); alert(dataObj); alert(dataObj.root.length);//输出root的子对象数量 $.each(dataObj.root,function(idx,item){ if(idx==0){ return true; } //输出每个root子对象的名称和值 alert("name:"+item.name+",value:"+item.value); }) </script> </head> <body> <input type="button" onclick='aaa()' value="获取" /> </body> </html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17