프론트엔드/JavaScript
Uncaught ReferenceError: $ is not defined 에러 처리
step 1
2022. 7. 17. 19:03
반응형
ajax 처리를 위해 코드를 작성하였는데 아래와 같은 에러 코드가 발생하였다.
$.ajax({
url:"/login/login",
type:"POST",
data:JSON.stringify(params),
contentType: "application/json",
success: function(result) {
if (result) {
alert("저장되었습니다.");
} else {
alert("잠시 후에 시도해주세요.");
}
},
error: function() {
alert("에러 발생");
}
})

원인: jquery 선언을 위에 안해주었기 때문에 발생
jquery cdn을 검색하여 코드에 추가해준다.
jQuery CDN
The integrity and crossorigin attributes are used for Subresource Integrity (SRI) checking. This allows browsers to ensure that resources hosted on third-party servers have not been tampered with. Use of SRI is recommended as a best-practice, whenever libr
releases.jquery.com

추가 후 에러가 발생하지 않는다.

반응형