The request to test3.php
will be cancelled, because you're not preventing the default behaviour of following the link to test2.php
.
Try the following;
$('#test').on('click', function(e) {
$.post('test3.php', { myvar : 'myvalue' } );
e.preventDefault();
});
You can then redirect to test2.php
when the request completes;
$('#test').on('click', function(e) {
var that = this;
$.post('test3.php', { myvar : 'myvalue' } ).done(function () {
window.location.href = that.href;
});
e.preventDefault();
});