dataString = 'param=stuff';
jQuery.ajax({
cache: false,
type: "POST",
headers: { "cache-control": "no-cache" },
url: "https://example.com/assets/mailer.php",
data: dataString,
success: window.location.href = "https://example.com/thankyou"
});
This works fine with various browsers on Windows, MacOS, and Android. On iOS, the PHP mailer script isn't triggered, but the redirect works. Using Safari dev tools I can see there aren't any errors in the console. What am I missing?
successaccepts a function, you are passing it a string while simultaneously assigning that string towindow.location.hrefand navigating away.Use a function instead...
Note that I've removed all the redundant options you were setting and used the safer method of encoding the request body.
FYI you definitely don't need jQuery for this