yoooz 2021. 10. 19. 16:56

검사>console에서 늘 테스트 할 것

         console.log(...);

 

2-6 퀴즈 3번 어려웠음

 

Ajax는 서버에서 데이터를 받아올 수 있는 방법

 

통상적으로,

GET: 데이터 조회 요청 시 사용

POST: 생성, 변경, 삭제 등 나머지 사용

 

2-9 퀴즈

<script>

function q1() {
    $('#names-q1').empty();
    $.ajax({
        type: "GET",
        url: "http://openapi.seoul.go.kr:8088/6d4d776b466c656533356a4b4b5872/json/RealtimeCityAir/1/99",
        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 > 60) {
                        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>