jQuery Ajax: redirect to other pages without wait the result

http, jquery

Solution

It looks like the script you're AJAX-ing to is sending an e-mail. I can see how waiting for that to complete would result in a lag on the user's end. Here's how I typically solve this problem:

Instead of having your mailer.php script immediately send the e-mail, store the message data in your db. Don't send the e-mail during the AJAX call. This will result in a very fast process for the user.

Then, you can setup a CRON job that points to a script you have specially created for sending out e-mails that have been stored in the DB.

Make sense?

Problem

After clicking on a button I want to fire an Ajax call and then redirect to other pages without waiting the ajax result. Is it possible? My code as follow: ``` $('button').click(function(){ $.get('mailer.php', function(){ window.location.replace("result.php"); }); }); ``` The code above will wait for the ajax result before redirection. Can I just let the ajax run at the back and move on to other pages?

Original source