커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
메소드 405오류
undefined주차
북마크
장*재
댓글
7
추천
0
조회수
17
조회수
17
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.



POST 방식으로 입력이 안 됩니다.


스파르타 즉문즉답




<!DOCTYPE html>
<html lang="en">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    #head {
    display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background-color: #ff7088;


   }
    #pic{
      width: 300px;
      height: 300px;
      margin: 20px 30px ;
      float: left;
    }
    #pr{
      background-color: #fFB9B9;

    }
    .table{
      border: 10px;
    }

     .mypost {

            max-width: 70%;
            margin: 20px auto 20px auto;

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

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

    .dis {
        width: 70%;
        height: auto;
    }
    .name {
        width: 200px;
        height: 50px;
 }

.bang {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;


 }

.line {
        padding: 8px;
        padding-right: 200px;
 }

    .comments > tr {
        border-color: inherit;
        border-style: solid;
        border-width: 0;
        border-bottom: 1px solid;
    }
 #box{

 }

  </style>
    <script>
         $(document).ready(function () {
            show_order();
        });
        function show_order() {
            $.ajax({
                type: 'GET',
                url: '/comment',
                data: {},
                success: function (response) {
                    let rows =response['orders']
                    for (let i = 0; i<rows.length; i++){
                        let name = rows[i]['name']
                        let comment = rows[i]['comment']

                        let temp_html = `
                                      <tr>
                                      <td>${name}</td>
                                      <td>${comment}</td>
                                      </tr>
                                      `
                        $('#box').append(temp_html)

                    }
                }
            });
        }


        function save_order(){
            let name = $('#name4').val()
            let comment = $('#comment4').val()
            $.ajax({
                type: 'POST',
                url: '/comment',
                data: {name_give:name,comment_give:comment},
                success: function (response) {
                    alert(response['msg'])
                    window.location.reload()
                }
            });
        }
    </script>
</head>
<body>
<!--배너-->
 <div id="head">
    <h1>나의 상세정보</h1>
  </div>
<!--사진-->
<div >
  <img id="pic" src="https://velog.velcdn.com/images/guwo8813/profile/63ebbcdc-08f8-40df-896d-338800e8e6e1/image.jpg"  alt="...">
</div>
<!--장단점, 자기소개칸-->
<div id="pr" >
  <table class="table" >
    <tr>
      <td><h2>이름</h2></td>
      <td>현재</td>
    </tr>
    <tr>
      <td><h2>자신 설명</h2></td>
      <td>나는 감자</td>
    </tr>
    <tr>
      <td><h2>MBTI</h2></td>
      <td>ENTJ</td>
    </tr>
    <tr>
      <td><h2>장점</h2></td>
      <td>ENTJ</td>
    </tr>
    <tr>
      <td><h2>협업 스타일</h2></td>
      <td>ENTJ</td>
    </tr>
    <tr>
      <td><h2>블로그 주소</h2></td>
      <td>벨로그</td>
    </tr>
   </table>
</div>
<!--방명록-->
<div class="mypost">
<div class="form-floating mb-3">
  <input type="" class="name" id="name4" placeholder="이름">
  <label for="name4"></label>
</div>
  <div class="form-floating">
  <textarea class="dis" placeholder="응원댓글" id="comment4" style="height: 100px"></textarea>
  <label for="comment4"></label>
    <button onclick="save_order()" type="button" class="btn btn-secondary">댓글 남기기</button>
</div>
</div>
<div class="comments">
    <table class="bang">
            <thead>
              <tr class="mit">
                <th class="line" scope="col">이름</th>
                <th class="line" scope="col">방명록</th>
              </tr>
            </thead>

            <tbody id="box">



            </tbody>
          </table>
</div>

</body>
</html>



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