jQuery $.post
함수를 호출하는 이벤트가 있습니다. $.post
함수 안에 정의 된 변수에 액세스하고 싶습니다. 문제가 있습니다.
이 경우 currentId
변수에 액세스하고 싶습니다.
$('.notMatching').click(function(){
var currentId = this.id;
$.post("http://"+ document.domain + baseUrl +"/tables/demo.json", { id: this.id },
function(dat){
alert(currentId); //undefined
if(dat['result']==1){
$(this).parent().html('<input type="checkbox" class="first" value="'+this.id+'">');
}
}
);
});
할 방법이 있습니까?
Btw,이 이벤트는 $(document).ready(function(){
안에 있으며 다른 많은 이벤트가 있습니다.
http://remysharp.com/2007/04/12/jquerys-this-demystified/ –