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.
jQuery.ajax({
type:"POST",
url:admin_ajaxurl,
dataType: "Json",
data: {
action: "lp_contact",
post: postData
},
beforeSend: function(jqXHR, data, setting){
},
success: function(data){
},
error: function(data) {
}
}); // End update prospect
window.location.replace("http://www.example.com/thank-you-landing-page/");
return false;