du5910 2016-04-07 06:09
浏览 88

Ajax调用嵌套的php文件

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.';
}
?>
  • 写回答

1条回答 默认 最新

  • douyi2107 2016-04-07 06:38
    关注
    url: "../../page_components/A.php"
    

    is that url supposed to be sending on B.php? if it is then isnt the url supposed to be like this

    url: "../../page_components/B.php"
    
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改