$(this)
exists in click event
, but function(data) {
not part of the click event rather callback function
. Therefore, save $ (this) in some variable, such as that
for future reference.
Try the following:
$('.delete-post').click(function(e) { e.preventDefault(); var that = $(this); $.post(that.attr('href'), { }, function(data) {
source share