<script>
function q1() {
$.ajax({
type: "GET",
url: "http://spartacodingclub.shop/sparta_api/rtan",
data: {},
success: function (response) {
let url =response['url']
let msg =response['msg']
$('#img-rtan').attr('src',url)
$('#text-rtan').text(msg)
}
})
}
- $('#').attr('',) - 이미지 바뀜
- $('#').text() - 메시지 바뀜
- 바뀌는 기능은 여러가지에 응용할 수 있다고 생각된다.
- 홈페이지를 들어가면 자동으로 날씨를 업데이트해줌
- 자동 업데이트 - $(document).ready(function () {
<script>
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://spartacodingclub.shop/sparta_api/weather/gumi",
data: {},
success: function (response) {
let temp = response['temp']
$('#temp').text(temp)
}
})
});
</script>
- temp_html에 대해서 조금 익숙해져 가는거 같다.