728x90
반응형
<script>
    function q1() {
                $('#names-q1').empty();
        $.ajax({
            type: "GET",
            url: "http://spartacodingclub.shop/sparta_api/seoulair",
            data: {},
            success: function (response) {
                let rows = response['RealtimeCityAir']['row'];

                for (let i = 0 ; i < rows.length; i++){
                    let gu_name = rows[i]['MSRSTE_NM'];
                    let gu_mise = rows[i]['IDEX_MVL'];

                    let temp_html = ``

                    if ( gu_mise > 30){
                        temp_html = `<li class="bad">${gu_name} : ${gu_mise}</li>`
                    }
                        else{
                            temp_html = `<li>${gu_name} : ${gu_mise}</li>`
                    }

                    $('#names-q1').append(temp_html);
                }

            }
        })
    }
</script>
<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 name = rows[i]['stationName']
                    let rack = rows[i]['rackTotCnt']
                    let bike = rows[i]['parkingBikeTotCnt']

                    let temp_html = ``

                    if ( bike < 5 ) {
                        temp_html = `<tr class="urgent">
                                        <td>${name}</td>
                                        <td>${rack}</td>
                                        <td>${bike}</td>
                                    </tr>`
                        } else {
                        temp_html = `<tr class>
                                        <td>${name}</td>
                                        <td>${rack}</td>
                                        <td>${bike}</td>
                                    </tr>`
                    }

                    $('#names-q1').append(temp_html)
                }

            }
        })
    }
</script>
<script>
    $.ajax({
        type: "GET",
        url: "http://spartacodingclub.shop/sparta_api/weather/seoul",
        data: {},
        success: function (response) {
            let temp = response['temp']
            $('#temp').text(temp);
        }
    })
</script>
728x90
반응형

'기초코드' 카테고리의 다른 글

Git Bash 작동코드  (0) 2022.10.27
OG태그  (0) 2022.10.27
★기본 CSS노말라이즈★  (0) 2022.10.21
인라인 그리드, 이미지 박스  (0) 2022.10.21
메뉴박스 노말라이즈  (0) 2022.10.20

+ Recent posts