I have a function name HideN which triggers when user click on a link like shown below
<a href="<?php echo $dn5['link']; ?>" onclick="HideN('<?php echo $dn5['id'];?>','<?php echo $dn5['from_user'];?>')" class="media">
this gives me
<a href="/page/example" onclick="HideN('25','username')" class="media">
Now i want to send an ajax request onclick, then redirect the user to /page/example
but it always abort the ajax request and redirect the page
function HideN(t, a) {
var e = {
id: t,
user: a
};
$.ajax({
type: "POST",
url: "https://www.example.com/ajax/hideN?status=hideIt",
data: e,
success: function(t) {}
})
};
How can i first send an ajax request then redirect the page after success response
the link is dynamically generated from database, every link will be different