|
轉(zhuǎn)載 [{"name":"中國工商銀行","code":102},{"name":"中國農(nóng)業(yè)銀行","code":103},{"name":"中國銀行","code":104},{"name":"平安銀行","code":307}] // code.json 文件 <script type="text/javascript">
$(function(){
$("#btn").click(function(){
$.getJSON("area/code.json",function(data){
var $jsontip = $("#jsonTip");
var $json = $("#json");
var strHtml = "";//存儲(chǔ)數(shù)據(jù)的變量
var json = "";//存儲(chǔ)數(shù)據(jù)的變量
$jsontip.empty();//清空內(nèi)容
$json.empty();//清空內(nèi)容
$.each(data,function(infoIndex,info){
strHtml += ""+info["name"]+"<br>";
json += ""+info["code"]+"<br>";
strHtml += "<hr>"
})
$jsontip.html(strHtml);//顯示處理后的數(shù)據(jù)
$json.html(json);//顯示處理后的數(shù)據(jù)
})
})
})
</script>
</head>
<body>
<div>
<input type="button" value="獲取數(shù)據(jù)" id="btn" />
</div>
<div id="jsonTip"></div>
<div id="json"></div>
</body>
</html> |
|
|