uncaught referenceerror $ is not defined 에러 해결 방법
조회수 54602회
코드를 실행시키면 $("#search").autocomplete 라인에
'uncaught referenceerror $ is not defined' 에러가 발생합니다.
에러의 이유가 jquery가 로드되지 않았기 때문인 것으로 알고 있는데 어떤 문제가 있는지 궁금합니다.
<script type="text/javascript">
(function () {
window.item_list = {{item_list|safe}};
})();
$("#search").autocomplete({
source: window.item_list
});
</script>
http://jqueryui.com/autocomplete/ 을 참고한 jquery 업로드 소스입니다.
<!-- autocomplete from jQuery Ui -->
<script src='{% static "js/jquery-1.11.3.min.js" %}'></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
아래는 jquery-1.11.3.min.js의 경로입니다.
-
(•́ ✖ •̀)
알 수 없는 사용자
2 답변
-
js/plugins/jquery-1.11.3.min.js
이게 빠진게 아닐까요?
그리고 1.11.3 버전을 사용하실꺼면 CDN의 1.12.4 버전은 빼시는게...
- 말씀하신대로 자동완성의 코드가 1.12.4 버전이어서 1.11.3 코드를 빼보았지만 해결이 되지 않네요 ㅠㅠ 답변감사합니다! 알 수 없는 사용자 2017.8.21 14:28
-
물론 코드가 이런 순서로 되어 있겠죠 ?
<body> 코드 블라 블라...... <script src='{% static "js/jquery-1.11.3.min.js" %}'></script> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script type="text/javascript"> (function () { window.item_list = {{item_list|safe}}; })(); $("#search").autocomplete({ source: window.item_list }); </script> </body> </html>
댓글 입력