1주차때 했던 homework에 실시간 날씨 적용하기

 

<body>
<div class="mytitle">
    <h1>박화요비 팬명록</h1>
    <p>  현재기온 : <span id="temp">00.0</span>도 </p>
</div>

p태그, span 태그 사용

$(document).ready(function ()

이번에는 클릭 후에 바뀌는게 아니라 로딩이 완료되면 ajax 콜을 해서 데이터를 가져와야 되기때문에 document 사용

 

<script>

    $(document).ready(function () {
        $.ajax({
    type: "GET",
    url: "http://spartacodingclub.shop/sparta_api/weather/seoul",
    data: {},
    success: function (response) {
        let temp = (response['temp'])
        $('#temp').text(temp)
    }



  })
    });


</script>

 

온도 옆에 해모양 아이콘은 실시간이 아닌거 같아서 그냥 빼는게 좋을듯 싶다.

 

 

 

 

+ Recent posts