My html is
<a class="delete" href="/FolderComment/delete/12">delete</a>
and my js is
$("a .delete").click(function(e){
//e.preventDefault(); --> tried that too
var href = this.attr("href");
$.post(
href, {},
function(data){
alert(data);
}
);
return false;
});
but it doesn’t work, the page gets redirected.
here is a jsfiddle
If your
hrefis prepended with #, you should be able to avoid redirection. I have forked your JS fiddle and added in the selector change from @Alnitak.