커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
숙제
undefined주차
북마크
윤*하
댓글
6
추천
0
조회수
10
조회수
10
답변 완료


닉네임과 응원댓글을 하고 응원남기기를 하면

post부분은 잘 나오는것 같습니다

get부분에서 밑에 temp_html 로 나오게 하는것 같은데 나오질 않습니다



스파르타 즉문즉답



작성한 코드 및 에러 메세지

<script>
    $(document).ready(function () {
        set_temp()
        show_comment()
    });

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

    function save_comment() {
        let name = $('#name').val()
        let comment = $('#comment').val()
        $.ajax({
            type: 'POST',
            url: '/homework',
            data: {name_give:name,comment_give:comment},
            success: function (response) {
                alert(response['msg'])
                window.location.reload()
            }
        })
    }

    function show_comment() {
        $.ajax({
            type: "GET",
            url: "/homework",
            data: {},
            success: function (response) {

                let rows=response('homeworks')
                for(let i=0;i<rows.length;i++){
                    let name=rows[i]['name']
                    let comment=rows[i]['comment']

                            let temp_html = `<div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>${comment}</p>
                    <footer class="blockquote-footer">${name}</footer>
                </blockquote>
            </div>
        </div>`
                    $('#comment-list').append(temp_html)
                }
            }
        });
    }
</script>



취소
 공유
취소
댓글 0
댓글 알림
나의얼굴