커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
5-4 코드스니펫 index.html 복사한게 좀 이상합니다.
undefined주차
북마크
서*
댓글
1
추천
0
조회수
6
조회수
6
답변 완료

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

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


index.html 그대로 붙여넣기 했는데 영상에서 보이는 것과 다른 조금 다른 코드가 복사 되는 것 같습니다.

function show_bucket() 부분에서

영상에선 console.log(data)

                alert(data['msg'])

로 나오는 부분이

// console.log(data)

로 되어있고

 window.location.reload(); 도 영상에선 따라하면서 넣게 되어있는데 이미 들어가 있습니다.


http://localhost:5000/

에 가보면

호주에서 스카이다이빙하기도 3개나 뜨는데 가운데 건 밑줄까지 되어있습니다.

수정해서 쓰려고 해봤는데

몽고 DB에서 이루고 싶은 걸 입력해도 샘플데이터로만 나오네요.

어떻게 고쳐야할지 모르겠어서 그냥 원래 복사해야 할 코드스니펫을 받고 싶습니다.







<!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" />


  <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>


  <link

   href="https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap"

   rel="stylesheet"

  />


  <title>인생 버킷리스트</title>


  <style>

   * {

    font-family: "Gowun Dodum", sans-serif;

   }

   .mypic {

    width: 100%;

    height: 200px;


    background-image: linear-gradient(

      0deg,

      rgba(0, 0, 0, 0.5),

      rgba(0, 0, 0, 0.5)

     ),

     url("https://images.unsplash.com/photo-1601024445121-e5b82f020549?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1189&q=80");

    background-position: center;

    background-size: cover;


    color: white;


    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

   }

   .mypic > h1 {

    font-size: 30px;

   }

   .mybox {

    width: 95%;

    max-width: 700px;

    padding: 20px;

    box-shadow: 0px 0px 10px 0px lightblue;

    margin: 20px auto;

   }

   .mybucket {

    display: flex;

    flex-direction: row;

    align-items: center;

    justify-content: space-between;

   }


   .mybucket > input {

    width: 70%;

   }

   .mybox > li {

    display: flex;

    flex-direction: row;

    align-items: center;

    justify-content: center;


    margin-bottom: 10px;

    min-height: 48px;

   }

   .mybox > li > h2 {

    max-width: 75%;

    font-size: 20px;

    font-weight: 500;

    margin-right: auto;

    margin-bottom: 0px;

   }

   .mybox > li > h2.done {

    text-decoration: line-through;

   }

  </style>

  <script>

   $(document).ready(function () {

    show_bucket();

   });

   function show_bucket() {

    fetch('/bucket').then(res => res.json()).then(data => {

        // console.log(data)

      })

   }


   function save_bucket() {

    let formData = new FormData();

    formData.append("sample_give", "샘플데이터");


    fetch('/bucket', {method: "POST",body: formData,}).then((response) => response.json()).then((data) => {

      alert(data["msg"]);

      window.location.reload();

     });

   }

    

  </script>

 </head>

 <body>

  <div class="mypic">

   <h1>나의 버킷리스트</h1>

  </div>

  <div class="mybox">

   <div class="mybucket">

    <input

     id="bucket"

     class="form-control"

     type="text"

     placeholder="이루고 싶은 것을 입력하세요"

    />

    <button onclick="save_bucket()" type="button" class="btn btn-outline-primary">기록하기</button>

   </div>

  </div>

  <div class="mybox" id="bucket-list">

   <li>

    <h2>✅ 호주에서 스카이다이빙 하기</h2>

    <button onclick="done_bucket(5)" type="button" class="btn btn-outline-primary">완료!</button>

   </li>

   <li>

    <h2 class="done">✅ 호주에서 스카이다이빙 하기</h2>

   </li>

   <li>

    <h2>✅ 호주에서 스카이다이빙 하기</h2>

    <button type="button" class="btn btn-outline-primary">완료!</button>

   </li>

  </div>

 </body>

</html>



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