<!-- 檔案:0914-5.html -->
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
	<style type="text/css">
		a{
			cursor: pointer;
		}
	</style>
</head>
<body>
	<div id="content"></div>
	<div id="reloadbox"></div>
	<script type="text/javascript">
		function getData(){
			var content='';
			$.getJSON('data/0914-5.json').done(function(data){
				$.each(data,function(index,value){
					content+='<h2>'+index+':'+value+'</h2>'
				});
				$('#content').html(content).hide().fadeIn();
			}).fail(function(){
				$('#content').text('沒有資料');
			}).always(function(){
				$('#reloadbox').html('<a id="reload">重新整理</a>');
				$('#reload').on('click',function(e){
					e.preventDefault();
					getData();
				});	
			});	
		}
		getData();
	</script>
</body>
</html>

檔案:data/0914-5.json

{
	"主餐":"漢堡",
	"飲料":"可樂",
	"價格":"500",
	"圖片":"https://api.fnkr.net/testimg/50x50/a00/FFF/?text=A"
}
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Jerry 的頭像
    Jerry

    Bug倉庫 // 程式日記

    Jerry 發表在 痞客邦 留言(0) 人氣()