How to pass return (callback) function parameter jquery — DOM element?

I mean: we have the element on click calling ajax request after returning the result to the server we need to do something with this item! But the principle fails in primitive use, which is understandable. Because we create the callback function is completely clean, it has an input parameter data only, but how?

$('.update').click(function(){
 $id = 12345;
 $.post('http://localhost/?UPDATE=true', {id: $id}, function(data){
 if(data == 'tr') { $(this).fadeOut () / * doesn't work */ }
});

});


How to pass callback function $(this)?
September 26th 19 at 12:03
1 answer
September 26th 19 at 12:05
Solution
So pass:
$('.update').click(function(){
 var id = 12345,
 $el = $(this);

 $.post('http://localhost/?UPDATE=true', { id: id }, function(data){
 if (data == 'tr') {
$el.fadeOut();
}
});
});
That only works if the transaction unit. And if, as I now have a cycle, then the time of arrival of the response from the server the variable $el is already peresechetsya on the last loop value.
Damn, what can I do)

upd: Hm, it is possible to function all together on top of the wrap. Sorry, blunted - Morton.Powlowski commented on September 26th 19 at 12:08

Find more questions by tags AJAXJavaScriptjQuery