I cant figure out why this wont redirect when everything looks in place.
I have used Location /path but just doesn\'t move from the main page.
Email sends and fo
php
if (mail($to, $subject, $message, $headers)) {
echo $redirect_thankyou;
die();
}
else
{
echo $redirect_error";
die();
}
javascript
$.post("hero-form.php", $("#register-form").serialize(),function(result){
if(result){
location.replace(result);
$('#hero-success-notification').addClass('show-up');
$('#hero-submit').addClass('disabled');
}
});
The problem is your php header redirect:
header("Location: $redirect_thankyou");
This causes the browser to load the redirected page in your ajax call:
$.post("hero-form.php", $("#register-form").serialize(),function(result){
So result
will contain the html contents of the page you have redirect to and not just the word sent
.
You need to remove the header()
redirects in php and instead send the content back that your ajax call in jQuery is expecting. Json would be better suited for this, but a single string should work as well.