중첩 된 함수의 외부 기능 소자 ..액세스 I가 변경 기능과 내부 Ajax를 갖는 각 기능을 JQuery와
$(".spring_explorations").each(function() {
$("#" + this.id + " select").change(function() {
alert("t");
$.ajax({
type: 'POST',
url: ('/admin/applications/get_sections_for_modal'), //pass query string to server
data: {
exploration_id: $("#" + this.id + " select").val()
},
success: function (response) {
$(this).parents('span').next().show();
$(this).parents('span').next().find("select").html(response);
console.log(response);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError);
}
})
});
});
I는 success
스니 spring_explorations
클래스 $(this)
요소에 액세스하고자 ajax
스크립트입니다.
context: this
을 추가하여 change
함수의 요소에 액세스 할 수 있었지만 어떻게하면 외부 요소를 얻을 수 있습니까?
고맙습니다.
편집 : 아마 this
가 아약스 자체가 아니라 spring_explorations
클래스이기 때문에
가 $(this).parents('span').next().show();
등이 정의되지 않습니다.
중복 된 질문 인 경우 대단히 죄송합니다. 나는 자바 스크립트에서 상당히 새롭다. 그리고 나는 이것이이 것에 대해 물어볼 적절한 장소라고 생각한다. 이것이 적절하지 않다고 생각되면 제 질문을 닫으십시오.
이것은 많은, 많은 질문의 사본입니다. – Nit
@Nit - 어느 것이 표준인가? –