J'ai un événement qui appelle la fonction jQuery $.post
. Je voudrais accéder à une variable définie à l'intérieur de la fonction $.post
et j'ai des problèmes avec cela.
Dans ce cas, j'aimerais accéder à la variable 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+'">');
}
}
);
});
Y a-t-il un moyen de le faire? Btw, cet événement est à $(document).ready(function(){
avec beaucoup d'autres événements.
http://remysharp.com/2007/04/12/jquerys-this-demystified/ –