javascript
[javascript] Cannot read property 'search' of undefined에러
tonirr
2020. 12. 24. 18:05
updatePassword:29 Uncaught TypeError: Cannot read property 'search' of undefined
at HTMLButtonElement.<anonymous> (updatePassword:29)
at HTMLButtonElement.dispatch (jquery.min.js:3)
at HTMLButtonElement.r.handle (jquery.min.js:3)
위와 같은 에러가 계속떠서
jquery js 파일에 문제가 있는 줄 알고 순서바꿔보고 버전도 바꿔보고했는데
아무리봐도 다른 jsp파일에서는 같은 jqeury로 search메소드를 잘 가져오길래 봤더니
npw.search()로 했을 때 npw가 undefined로 되어있어서 search메소드가 되지 않는 거였다.
search() 메소드를 사용할 떄에는 대상이 되는 변수에 값이 들어가 있는지 확인할 것
값이 들어가지 않은 이유는
input에 id를 두개 넣고 value를 가져오려고 했음
input에 name, class, id이 하나씩 선언 되어있는지 꼭 확인하기