PHP:在ajax请求中呈现包含的文件

时间:2015-06-16 08:04:40

标签: php ajax

我有以下文件

 /includes
     - file_inc1.php
     - file_inc2.php
 ajax.php
 index.php

index.php向ajax.php调用ajax请求,ajax.php调用类似下面的代码

$nextStep = $_GET["nextStep"];
if($nextStep == 1) {
  include "includes/file_inc1.php";
} else if($nextStep == 2) {
  include "includes/file_inc2.php";
}

有了这个设置,有没有人知道为什么ajax返回的响应是空的?

2 个答案:

答案 0 :(得分:1)

$nextStep = $_GET["nextStep"];
if($nextStep == '1') {
  include "includes/file_inc1.php";
} else if($nextStep == '2') {
  include "includes/file_inc2.php";
}

答案 1 :(得分:0)

感谢您的所有回复。我能够解决自己的问题。我需要确保在我的includes / file_inc1.php和includes / file_inc2.php文件中,我使用ob_start()和ob_get_clean(),如下所示:

SELECT first_name, last_name
FROM swimmers
WHERE NOT trim(first_name) LIKE '%a' AND gender = 'Female';