in jquery, i need to delay the default behavior of anchors, so that in the meantime, ajax post request can complete itself.
preventDefault or returning false in .click event wont do, as I still need to navigate to those pages. window.location = href obviously fails because some anchors do not have href attribute instead uses javascript. I do not control these pages.
If some anchors don't have href, I guess you'll not be able to change their behaviour. For the rest, just use a timeout on the click event and get href in order to redirect after the timeout ends, using its callback funcion.
You just use the 'success' callback within the ajax function for jQuery itself
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
// do what you need to here
return true;
}
});
Then it will wait until the Ajax has completed before moving on to the success callback