JQuery Ajax: redirecting to other pages without waiting for a result

After clicking the button, I want to start an Ajax call, and then redirect to other pages without waiting for the ajax result. Is it possible? My code is as follows:

$('button').click(function(){
    $.get('mailer.php', function(){
        window.location.replace("result.php");
    });
});

The above code will wait for the ajax result before redirecting. Can I just run ajax on my back and go to other pages?

+5
source share
3 answers

It looks like the script you're AJAX-ing is sending an email to. I see how the wait for this will end, which will lead to a delay with the end user. Here is how I usually solve this problem:

, mailer.php script , db. AJAX. .

CRON, script, , .

?

+2

, ( , ), . : .

+2

, . , , jQuery ajax.

, PHP ignore_user_abort(), true , .

+1

All Articles