Click on the link and make the browser is loading until you can redirect
Need help, I want you to click on a link while the browser continue to wait until I can make an ajax process, I have tried many ways but has no effect. How could you do this?
Note: I need the browser is in the process of "loading" as if it were a normal link
I have tried several ways but I can not have that effect.
- //example 1
-
$( "a" ).click(function() {
$( ".result" ).load("ajax.php"); // this file php have sleep 10 seconds
});
//example 2
$(window).unload(function() {
alert("bbb1");
});
//example 3
$(window).bind('beforeunload', function(e) {
$.ajax('ajax.php', {
async: false,
type: 'POST',
complete: function() {
e.preventDefault();
// capture the href attribute of the a element
var url = $(this).attr('href');
$(this).attr('href','');
// perform a get request using ajax to the captured href value
window.location.href="1.html";
}
});
});
//example 4
$( window ).on( 'beforeunload' , function( e ) {
e.stopPropagation();
// e.preventDefault();
alert("bbb");
} );