커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
5주차 팬명록 index.html 한 번 봐주시면 감사하겠습니다!
undefined주차
북마크
유*승
댓글
6
추천
0
조회수
18
조회수
18
답변 완료

팬명록을 만들어서 서버 연동와 IP연동까지 다 했습니다만, index.html에서 뭐가 잘못됐는지, 등록 완료 된 댓글(‘카드’)가 쌓이질 않습니다.


Index.html 코드 전체 올려드리니 확인 한 번 부탁드립니다.


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta property="og:title" content="최민식 팬명록"/>
    <meta property="og:description" content="응원 한마디 남기고 가세요!"/>
    <meta property="og:image" content="https://mblogthumb-phinf.pstatic.net/MjAxNzA4MDJfMTY2/MDAxNTAxNjE5MDM0MTI0.D6gaQKhb3UHzIZ8faSwVx5ogZPjtpIAcHWF3N5qL7Zgg.Y8e1SA-LID1s3QLr1rReIbFbuBebK3O_v3JUAu6JqjMg.PNG.yubin8200/image_2848616201501618795101.png?type=w800"/>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossorigin="anonymous"></script>

    <title>초미니홈피 - 팬명록</title>

    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@200;300;400;500;600;700;900&display=swap" rel="stylesheet">
    <style>
        * {
            font-family: 'Noto Serif KR', serif;
        }
        .mypic {
            width: 100%;
            height: 300px;

            background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://mblogthumb-phinf.pstatic.net/MjAxNzA4MDJfMTY2/MDAxNTAxNjE5MDM0MTI0.D6gaQKhb3UHzIZ8faSwVx5ogZPjtpIAcHWF3N5qL7Zgg.Y8e1SA-LID1s3QLr1rReIbFbuBebK3O_v3JUAu6JqjMg.PNG.yubin8200/image_2848616201501618795101.png?type=w800');
            background-position: center 30%;
            background-size: contain;

            color: white;

            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .mypost {
            width: 95%;
            max-width: 500px;
            margin: 20px auto 20px auto;

            box-shadow: 0px 0px 3px 0px black;
            padding: 20px;
        }

        .mypost > button {
            margin-top: 15px;
        }

        .mycards {
            width: 95%;
            max-width: 500px;
            margin: auto;
        }

        .mycards > .card {
            margin-top: 10px;
            margin-bottom: 10px;
        }
    </style>
    <script>
        $(document).ready(function () {
            show_comment();
        });
        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() {
            $('#comment-list').empty()
            $.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>${comment}</p>
                                                    <footer class="blockquote-footer">${name}</footer>
                                                </blockquote>
                                            </div>
                                        </div>`
                        $('#comment-list').append(temp_html)
                    }
                }
            });
        }
    </script>
</head>
<body>
    <div class="mypic">
        <h1>최민식 팬명록</h1>
        <p>현재기온: <span id="temp">36</span>도</p>
    </div>
    <div class="mypost">
        <div class="form-floating mb-3">
            <input type="text" class="form-control" id="name" placeholder="url">
            <label for="floatingInput">닉네임</label>
        </div>
        <div class="form-floating">
            <textarea class="form-control" placeholder="Leave a comment here" id="comment"
                style="height: 100px"></textarea>
            <label for="floatingTextarea2">응원댓글</label>
        </div>
        <button onclick="save_comment()" type="button" class="btn btn-dark">댓글 남기기</button>
    </div>
    <div class="mycards" id="comment-list">
        <div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>한산 보고 왔는데, 명량의 최민식 배우님이 생각나네요!</p>
                    <footer class="blockquote-footer">아트큐브<cite title="Source Title"></cite>
                    </footer>
                </blockquote>
            </div>

        </div>
        <div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>레전드급 연기파!</p>
                    <footer class="blockquote-footer">배우 지망생<cite title="Source Title"></cite>
                    </footer>
                </blockquote>
            </div>

        </div>
        <div class="card">
            <div class="card-body">
                <blockquote class="blockquote mb-0">
                    <p>느그 서장 남천동 살제?! 어?! 내가 임마! 느그 서장이랑 임마! 어저께도! 어?!</p>
                    <footer class="blockquote-footer">명대사 제조기<cite title="Source Title"></cite>
                    </footer>
                </blockquote>
            </div>

        </div>
    </div>
</body>
</html>


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