I am doing a ajax
POST
request to a php
file. Lets call it A.php
This A.php
file would then call B.php
.
$.ajax({
type: "POST",
url: "../../page_components/A.php",
data: { // my data
},
success: function(response) {
location.reload();
},
Problem Facing: The success function is not called when A.php calls B also. It works fine if A.php doesn't call B.php
On my A.php
/* some stuff that a.php does
*/
include ('B.php'); // call B.php to handle other stuff
B.php
<?php
require '../../../../PHPMailer/class.phpmailer.php';
require '../../../../PHPMailer/class.smtp.php';
// set relevant agency email to send to. $agency comes from A.php
switch ($agency) {
case "1": $receiverEmail = "xxx@hotmail.com";
break;
case "2" : $receiverEmail = "zzz@gmail.com";
break;
}
$mail = new PHPMailer();
// All the mail setting and stuff is here...
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>