원리를 모르니까 계속 헛도는 느낌...
핑 찍는거 계속 헷갈린다
이번 숙제는 달러-원 환율:(금액) 에서 금액값 불러오는거 했음
$(document).ready(function() {
// func();
});
정답
<style>
.rate_color {
color:blue;
}
</style>
<script>
$(document).ready(function() {
get_rate()
});
function get_rate() {
$.ajax({
type: "GET",
url: "https://api.manana.kr/exchange/rate.json",
data: {},
success: function (response) {
let now_rate = response[1]['rate']
$('#now_rate').text(now_rate)
}
})
}
</script>
<body>
<p class="rate_color">달러-원 환율:<sapn id="now_rate">9999</sapn></p>
</body>
내가한거
<script>
$(document).ready(function () {
q1();
});
function q1() {
$.ajax({
type: "GET",
url: "https://api.manana.kr/exchange/rate.json",
data: {},
success: function (response) {
let rate = response[1]['rate']
let temp_html = `<p id="q1">달러·원 환율:rate</p>`
$('#q1').append(temp_html)
}
})
}
</script>
<body>
<p id="q1"></p>
</body>