[error] ReferenceError: '' is not defined

HMS·2022년 10월 6일

넘겨주는 파라미터의 변수설정이 제대로 되지않아 발생한 오류

매개변수에 '따옴표 처리를 하지않아 변수정의가 되지않았었다.

for(var i in rList){
						str += "<tr><td width='100'>" + rList[i].replyWriter +  "</td>"
						str += "<td>" +  rList[i].replyContents +  "</td>"
						str += "<td>" +  rList[i].rUpdateDate +  "</td>"
						str += "<td><a href='javascript:void(0);' onclick='modifyReply(this,\""+rList[i].replyContents+"\","+rList[i].replyNo+")'>수정</a>/" 
						str += "<a href='javascript:void(0);' onclick='removeReply(this,\""+rList[i].replyWriter+"\","+rList[i].replyNo +")'>삭제</a></td></tr>"
					
					}
						$("#rtb").html(str);

해결

  1. 홑따옴표 안에서는 쌍따옴표를 써야 인식이된다
  2. onclick="test(num,'String')" 홑따옴표를 넣어줘야 스트링값으로 인식을 한다 '\' 역슬래시를 넣어줘서 해결

출처 : https://kimfk567.tistory.com/72

profile
안녕하세요

0개의 댓글