Research/HTML

shootingstar_HTML_$ is not defined

RIEM 2023. 4. 16. 21:15

리스트 태그들을 추가해주는 버튼을 추가했다. 그런데 버튼을 누르면 아래와 같은 에러가 발생했다.

버튼의 코드는 이렇다.

<button
  onclick='getNews()'
  type='button'
  class='btn btn-outline-secondary mb-3'>Scan the world
</button>

 

해결

...
<script src="http://code.jquery.com/jquery-3.5.1.min.js"></script>

    <script>
      function getNews() {
        $.ajax({
          type: "GET",
          url: "localhost:3000/news",
          data: {},
          success: function(response) {
            console.log(response);
          }
        })
      }
    </script>
  </body>
  ...