I want to create an ajax delete call. When the link is clicked, the confirm box should appear and then the p tag fades out (comment). The problem is just how the ajax call should be and how to show the confirm box.
HTML view:
<a rel="nofollow" data-method="delete" data-confirm="Er du sikker?" class="softdelete" href="/blogs/5/comments/18">slet</a>
jQuery:
<script type="text/javascript">
$(document).ready(function() {
$('.softdelete').click(function () {
var Url = $(this).attr('href');
var Data = $(this).attr('data-method');
$(this).closest('p').fadeOut(1000);
$.post(Url);
return false;
});
});
</script>
When clicked on the delete link, the comment fades out, but it is not destroyed. Also no confirm box appeared.