I'm posting a form to admin-ajax and the redirect use to be within the success handler. That was taking too long to receive from the server then redirect, even though it was only a small json response giving a success message. I've since moved the redirect to execute after the .ajax() call. Is there any chance the redirect could execute before the AJAX posted? I know AJAX is asynchronous so it's executing in the background.

      dataType: "Json",
      data: {
        action: "lp_contact",
        post: postData
      beforeSend: function(jqXHR, data, setting){

      success: function(data){          

      error: function(data) {

    }); // End update prospect
    return false;

The problem could be in using admin ajax. If you switch to a different endpoint, the process may speed up.

I've used ajax flow on a few sites and you should see a performance gain: https://wordpress.org/support/view/plugin-reviews/ajaxflow

Check out some best practices here:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.