Develope/jQuery

[jQuery]a.indexOf is not a function 에러가 발생할 때

oper0116 2020. 6. 25. 16:54
반응형

a.indexOf is not a function 에러가 발생할 때

발생원인

Uncaught TypeError: a.indexOf is not a function at r.fn.init.r.fn.load 에러 발생하여 확인해보니,
jQuery 1.8 버전 이후로 load() unload() error()deprecated 되었으며, jQuery 3.0 버전 이후 해당 기능은 제거되어 발생하는 현상이다.

load(), error(), unload()의 자세한 내용은 jQuery 페이지에서 API Documentation에 가서 자세한 내용을 확인할 수 있다.

문제해결

해당 에러 발생한다면 현재 사용하고 있는 jQuery 버전을 확인 후 jQuery 3.0 미만 버전으로 변경하거나, jQuery 3.0 이상 버전을 사용해야 한다면, load() unload() error()를 어떻게 사용하고 있는지 확인을 해야 하며, 아래와 같이 해당 부분을 변경하면 된다.

// 기존 사용
$(window).load(function(){ ... });

// jQuery 1.8 이후 버전에서 사용할 경우
$(window).on('load', function(){ ... });

참고자료

https://stackoverflow.com/questions/38871753/uncaught-typeerror-a-indexof-is-not-a-function-error-when-opening-new-foundat

반응형