Page 539 - MDP2022-3
P. 539
in.js">
</script>
<title>급식 조회</title>
<script src="http://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(function () {
let y = new Date();
y.setDate(y.getDate() - 1);
let str = y.getFullYear() + "-" +
("0" + (y.getMonth() + 1)) + "-" +
("0" + y.getDate());
$("#date").attr("max", str);
// 버튼 클릭 이벤트
$("#mybtn").click(function () {
let d = $("#date").val(); //YYYY-MM-DD
const regex = /-/g;
let d_str = d.replace(regex, "") // YYYYMMDD
let url =
"https://open.neis.go.kr/hub/mealServiceDietInfo?KEY=3b4a564de87341d99278fb2fe19
e708f&Type=json&pIndex=1&pSize=100&ATPT_OFCDC_SC_CODE=E10&SD_SCHUL_CODE=7310370&ML
SV_YMD="+d_str
$.getJSON(url, function (data) {
if (data.mealServiceDietInfo != null){
let mealList = data.mealServiceDietInfo[1];
$("span").empty();
$("span").append("<br><br><strong><h5>"+ d + "의 급식</h5></strong><br><br>
");
for (var i = 0; i < mealList.row.length; i++) {
$("span").append("<div><strong><h5>" + "<b><" + mealList.row[i].MMEAL_S
C_NM + "></b>" + "<br><br>" + mealList.row[i].DDISH_NM + "</h5></strong></div><hr>");
}
}
else {
$("span").empty();
$("span").append("<div><br><strong><h5>급식 데이터가 없습니다.</h5></strong>
<br></div>");
}
});
}); //click
}); //ready
</script>
</head>
<body>
<header class="py-2">
<div class="container px-lg-5">