ν΄μ¦ μ μ€μ΅ν λ΄μ©μ κ°μ§κ³ κ°μ Έμ λΆμ΄κ³
λκ°μ΄ λ°λΌμ μΉκΈ°λ νκ³ ν΄λΉνλ μ리μ μ λ£μλ€κ³ μκ°νλλ°..
μ λ°°μ΄ μ μλ κ² κ°μ μμμ νμ©ν΄μ λ°μνκ² ν΄μΌνλ 건μ§..
μλλ©΄ μ μλλ λͺ¨λ₯΄λ μ€μ΅μλ€μ μ΄λ¬ν κ²½μ°μ λν΄μλ λ―Έμ² μκ°μ λͺ»νμ 건μ§..
(κ·Έλ₯ μνλ κ²°κ³Όκ° λμ€μ§ μμμ ννμ΄νλ μ€..)
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>JQuery μ°μ΅νκ³ κ°κΈ°!</title>
<!-- JQueryλ₯Ό import ν©λλ€ -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style type="text/css">
div.question-box {
margin: 10px 0 20px 0;
}
table {
border: 1px solid;
border-collapse: collapse;
}
td,
th {
padding: 10px;
border: 1px solid;
}
.bad {
color: red;
}
</style>
<script>
function q1() {
// μ¬κΈ°μ μ½λλ₯Ό μ
λ ₯νμΈμ
$('#names-q1').empty()
$.ajax({
type: "GET",
url: "http://spartacodingclub.shop/sparta_api/seoulbike",
data: {},
success: function (response) {
let rows = response['getStationList']['row']
for (let i = 0; i < rows.length; i++) {
let location = rows[i]['stationName']
let count = rows[i]['rackTotCnt']
let max = rows[i]['parkingBikeTotCnt']
let temp_html = ``
if (max > 5) {
temp_html = `<td class="bad">${location} : ${count} : ${max}</td>`
} else {
temp_html = `<td>${location} : ${count} : ${max}</td>`
}
$('#names-q1').append(temp_html)
}
}
})
}
</script>
</head>
<body>
<h1>jQuery + Ajaxμ μ‘°ν©μ μ°μ΅νμ!</h1>
<hr />
<div class="question-box">
<h2>2. μμΈμ OpenAPI(μ€μκ° λ°λ¦κΈ° νν©)λ₯Ό μ΄μ©νκΈ°</h2>
<p>λͺ¨λ μμΉμ λ°λ¦μ΄ νν©μ 보μ¬μ£ΌμΈμ</p>
<p>μ
λ°μ΄νΈ λ²νΌμ λλ₯Ό λλ§λ€ μ§μ λ€ μλ‘ μμ¬μ ΈμΌ ν©λλ€.</p>
<button onclick="q1()">μ
λ°μ΄νΈ</button>
<table>
<thead>
<tr>
<td>κ±°μΉλ μμΉ</td>
<td>κ±°μΉλ μ</td>
<td>νμ¬ κ±°μΉλ λ°λ¦μ΄ μ</td>
</tr>
</thead>
<tbody id="names-q1">
<tr>
<td>102. λ§μμ 1λ²μΆκ΅¬ μ</td>
<td>22</td>
<td>0</td>
</tr>
<tr>
<td>103. λ§μμ 2λ²μΆκ΅¬ μ</td>
<td>16</td>
<td>0</td>
</tr>
<tr>
<td>104. ν©μ μ 1λ²μΆκ΅¬ μ</td>
<td>16</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
λ¬Έμ κ° μ€ν¬λ¦½νΈ λΆλΆμΈλ°..
κ³μ λκ° μμ ν΄λ΄λ
μ΄λ° μμΌλ‘ ν μΉΈμ μΈκ·Έλ¦¬ λ€μ΄κ°λ²λ¦°λ€..
μλν건 μ΄λ°κ±΄λ°.. μ μ΄λ° λΆλΆμ λ΄κ° λͺ¨λ₯΄λκ±ΈκΉ..
μμ°μ€λ¬μ΄κ±ΈκΉ..
λκ° μμ² λ§μκ°λ©΄μ λ°°μ°λ κΈ°λΆ.. κΈ λλ€..!!!
μΌμΌμΌμΌμ΄μ΄μ΄μ΄μ΄μ΄μ΄μμ΄μ΄μ΄μ΄!!!!!!!!! (μ€μ±)
15λΆλ 짧λ€.. 50λΆλμ μ‘κ³ μμλλ°..
ν΄κ²° λͺ»νλ λμμ λκ° λμ΄μ§λ μλ¦¬κ° λ€λ¦Ό.. ^^