이 오류가 발생하며 jquery 프레임 워크에서 발생합니다. 문서에서 선택 목록을로드하려고하면이 오류가 발생합니다. 왜이 오류가 발생하는지 찾을 수 없습니다.잡히지 않은 TypeError : 정의되지 않은 'toLowerCase'속성을 읽을 수 없습니다.
변경 이벤트에서 작동하지만 수동으로 함수를 실행하려고하면 오류가 발생합니다.
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined -> jquery-2.1.1.js:7300
다음은 '이'다른이 있기 때문에 그것은 "when trying to execute the function manually
"실패 코드
$(document).ready(function() {
$("#CourseSelect").change(loadTeachers);
loadTeachers();
});
function loadTeachers() {
$.ajax({
type: 'GET',
url: '/Manage/getTeachers/' + $(this).val(),
dataType: 'json',
cache: false,
success:function(data) {
$('#TeacherSelect').get(0).options.length = 0;
$.each(data, function(i, teacher) {
var option = $('<option />');
option.val(teacher.employeeId);
option.text(teacher.name);
$('#TeacherSelect').append(option);
});
},
error: function() {
alert("Error while getting results");
}
});
}
와 기능, 나는 .val() (이) "$을 변경했다; " "$ (this.target) .val();" –
'$ (this) .val()'도 올바른 사용법이 될 것입니다. –
그러나 우리가 도울 수 있다면'this'를 사용하지 않으려합니다. 'this'를 사용하면 코드를 유지하기가 더 어려워집니다. – Bobort