커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
홈워크에서 응원하기 댓글 다는거가 보이지 않아요
undefined주차
북마크
정*미
댓글
7
추천
0
조회수
16
조회수
16
답변 완료



몽고디비에도 3개의 댓글이 있는데 연결이 잘못된건지 덧글입력과 기존것들이 안보입니다.


http://hist-jm.shop/


index.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['comments']
                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>${name}</p>
                                                <footer class="blockquote-footer">${comment}</footer>
                                            </blockquote>
                                        </div>
                                    </div>`
                    $('#comment-list').append(temp_html)
                }
            }
        });
    }
</script>





스파르타 즉문즉답







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