ajax - PHP Exit() won't pass message after else statement
one text
I have a PHP Script that get call using AJAX
$.ajax({
url: "phpscript/testform.php",
type: "POST",
data: {'data':formData},
success: function(response){
if(response == "OK"){
console.log("!!");
$("#email_sent_modal").modal('show');
}
if(response == "WRONG"){
console.log("Email already exists!");
}
if(response == "NOTSET"){
console.log("Info Not Set!");
}
}
})
Everything works fine for response =="WRONG" and response =="NOTSET"
Except for response =="OK" after MAIL for some reason. note i do not include everything above, just the important part
This is my PHP Code
if($conn){
//SQL PREPARE STATEMENT TO INSERT INTO DATABASE
$sql = "INSERT INTO signup (email, psw, name, lastname, company, token)
VALUES ('$email', '$password','$name','$lastName','$company','$token') ";
if ($conn->query($sql) === TRUE){
$to = $email;
$subject = "Finish signing up your ID";
$htmlContent = '<html>
<head>
<title>Password Reset</title>
</head>
<body>
<h4>Dear ' . $name . ' </h4>
<p>
Finish signing up your ID. To complete the process, click the link below. </p>
<p> <a href="www.google.com'">Link </a>
</body>
</html>';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$mail($to, $subject, $htmlContent, $headers);
exit("OK");
}
}
the SQL mailing all works, i receive email and the sql database inserted perfectly, just the exit("OK") does not send back to ajax and can't show the nothing appears on console log
Source