在这种情况下,我如何在ajax调用中包含php文件


How can I include a php file in ajax call in this situation?

我正在尝试包含一个php文件

在ajax调用的文件中。例如,下面的代码,.ajaxurl是search.php,所以我想包含'fiel.php';在我的search.php中,我该怎么做?

$.ajax({
    url:'search.php',
    data:{ search_text: $(".result_tag").text()
},
    error: function(){
        $('#find_members').html('<p>An error has occurred</p>');
},
    success: function(data){
        $("#find_members").html(data);
},
    type:'POST' 
});

search.php

<?php
//this is search.php
include 'file.php';
echo test(); //try to testing
?>

file.php

//this is file.php
<?php
function test(){
echo"hello";}
?>

HTML

<div id="find_members"></div>

尝试将"fiel.php"包含到"search.php"文件