πŸ‘Ά 내일배움단/μ›Ήκ°œλ°œ μ’…ν•© κ°œλ°œμΌμ§€

Ajax(풀이)_

  • -

ν•œ 번 웃고 κ°€μž

 

 

[μ‹€μ„±]

 

μ„ μƒλ‹˜ : λ°°μš΄λŒ€λ‘œ κ°€μ Έλ‹€κ°€ λΆ™μ—¬μ„œ ν•˜μ‹œλ©΄ λ©λ‹ˆλ‹€ ^^

 

λ‚˜ : λ„€~ (κ·Έ 전에 배운걸둜 볡사 λΆ™μ—¬λ„£κΈ° ν•˜λ©΄ λ˜κ² μ§€~? νžˆνž›)

 

[λͺ‡μ‹­λΆ„ λ’€]

 

λ‚˜ : μ™œ κ·ΈλŒ€λ‘œ 따라 ν–ˆλŠ”λ° μ•ˆλ˜λŠ”κ±°μ§€..?

 

μ„ μƒλ‹˜ : 자~ μ΄λ ‡κ²Œ ν•˜λŠ”κ±°μ˜€μ–΄μš”~~ (μ™„μ „ μ²˜μŒλ³΄λŠ” μ‘μš©λ²•)

 

λ‚˜ : μ™€ν•˜ν•˜..!! μ €κ±Έ 배운거라고 μ‹œν‚€μ‹œλ‹€λ‹ˆ ^^

μš°λ¦¬μ—κ²Œ λ„ˆλ¬΄ μ•Œμž˜λ”± μŠ€νƒ€μΌμ„ μ›ν•˜μ‹œλŠ” 것 같은데?

 

 


 

μ‹€μŠ΅)

<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 location = rows[i]['stationName']
                        let count = rows[i]['rackTotCnt']
                        let max = rows[i]['parkingBikeTotCnt']

                        let temp_html = ``
                        if (max > 5) {
                            temp_html = `<td class="bad">${location} : ${count} : ${max}</td>`
                        } else {
                            temp_html = `<td>${location} : ${count} : ${max}</td>`
                        }
                        $('#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 = `<tr>
                                            <td>${name}</td>
                                            <td>${rack}</td>
                                            <td>${bike}</td>
                                        </tr>`
                        $('#names-q1').append(temp_html)
                    }
                }
            })
        }
    </script>

 

 

 

μ•„λ‹ˆ.. 배운거 λ§žλƒκ³ μš”..

 

λ¬Όλ‘  λ°°μš°λŠ” μž…μž₯에선 λ‹€ μƒˆλ‘­κ³  λ†€λžμ§€λ§Œ

 

κ·Έλž˜λ„.. λ‚―μ„  방법 λ‚―μ„  μ½”λ“œ λ‚―μ„  λ§₯락 λ“±λ“± λͺ¨λ“ κ²Œ λ‹€ λ‚―μ„€κ³  그런데..

 

[15λΆ„ λ°›κ³  μ§€λ‚œ λ’€]

 

μ„ μƒλ‹˜ : 자 ν• λ§Œ ν•˜μ…¨μ£ ? ^^

 

λ‚˜ : γ…‚γ„·γ…‚γ„·..

 

 

 

μ‘μš©)

<style type="text/css">
        .bad {
            color: red;
        }
</style>

    <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="bad">
                                            <td>${name}</td>
                                            <td>${rack}</td>
                                            <td>${bike}</td>
                                        </tr>`
                        } else {
                            temp_html = `<tr>
                                            <td>${name}</td>
                                            <td>${rack}</td>
                                            <td>${bike}</td>
                                        </tr>`
                        }
                        $('#names-q1').append(temp_html)
                    }
                }
            })
        }
    </script>

 


μŠ¨μƒλ‹˜.. κ·Έλž˜λ„ κΎΈμ—­κΎΈμ—­ 잘 λ”°λΌκ°”μ–΄μš”..

 

제발 뒀쳐진 κ΅μœ‘μƒλ“€ 버리지 λ§ˆμ‹œκ³ .. 끌고 κ°€μ£Όμ„Έμš”.. μ—‰μ—‰..

 

["ν• λ§Œ ν•˜μ‹œμ£ ~? ^^" λΌλŠ” 말이 제일 μ•Όμ†ν•˜λ‹€..]

Contents

ν¬μŠ€νŒ… μ£Όμ†Œλ₯Ό λ³΅μ‚¬ν–ˆμŠ΅λ‹ˆλ‹€

이 글이 도움이 λ˜μ—ˆλ‹€λ©΄ 곡감 λΆ€νƒλ“œλ¦½λ‹ˆλ‹€.