我有一個事件,它調用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+'">');
}
}
);
});
有沒有辦法做到這一點?
順便說一下,這個事件在$(document).ready(function(){
裏面還有很多其他事件。
http://remysharp.com/2007/04/12/jquerys-this-demystified/ –