{
"potato": [{
"name": "OK",
"drink": "available",
"side": {
"potato": "takes 5min",
"sticks": "taks 10min",
"goldwings": "takes 15min"
}
},
{
"name": "OK",
"drink": "available",
"side": {
"potato": "takes 5min",
"sticks": "taks 10min",
"goldwings": "takes 15min"
}
}]
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<title></title>
<script type="text/javascript">
$(document).ready(function(e) {
//data => potato json 객체
$.getJSON( 'test', function(data) {
var strResult="";
$.each(data.potato, function(obj1, value1) {
//obj1 값
strResult += "<li>"+value1.name + "</li>";
strResult += "<li>"+value1.drink + "</li>";
//side - 객체
$.each(value1.side, function (obj2, value2){
strResult += "<li>"+value2 + "</li>";
});
});
// ul 엘리먼트의 내용에 생성된 마크업 추가함
$("#result").append(strResult);
strResult = "";
});
});
</script>
</head>
<body>
<ul id="result">
</ul>
</body>
</html>
- OK
- available
- takes 5min
- taks 10min
- takes 15min
- OK
- available
- takes 5min
- taks 10min
- takes 15min
댓글 ( 4)
댓글 남기기