Why you just output the url in php side and then in the javascript side you call the script that you want:
PHP Side
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) {
echo "{'url':'contact_page.html#contactSuccess'}";
} else {
echo "{'url':'contact_page.html#contactError'}";
}
Javascript Side
complete: function(){
...
window.location = s.responseJSON.url
...
}
5
solved How change PHP Email form (return section) to match with Javascript and html template?