I am attempting the following:
When a user clicks a link, I want to update a specific column of a specific table in the database via ajax. BUT I still want the user to be redirected to the href="<url>"
of the link.
I tried jQuery without return false;
but then the ajax doesn't work.
I tried with return false;
but then the page obviously doesn't redirect to the url as I wanted.
Thanks in advance for your help.
Do your AJAX call, then set document.location
when done.
$('a').click(function(e){
var href = this.href; // get href from link
e.preventDefault(); // don't follow the link
$.ajax({
url: '/path/to/site',
data: {some: data},
success: function(){
document.location = href; // redirect browser to link
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With