$(this)
exists in the click event
but function(data) {
is not part of click event rather callback function
. So save the $(this) in some variable for instance that
for later use.
Try this:
$('.delete-post').click(function(e) {
e.preventDefault();
var that = $(this);
$.post(that.attr('href'), { }, function(data) {
// $(this).closest('.post').remove();
that.closest('.post').remove();
});
});