如何将php页面成功包含到ajax函数中



我想在ajax成功函数中包含一个PHP文件。是否可以在ajax函数中添加PHP文件?我的PHP文件是list.php我的ajax函数是:

function fn_nextitem(sliderNo){

$.get("/index.php?op=ajax", {slide_no:sliderNo},function(resp) {
if (resp) {
obj_b = JSON.parse(resp);
if(obj_b) {
$('#Div').html(obj_b);
}
else {

} 
}
我的PHP代码是这样的:
if(!empty($items )){  
foreach ($items as $itemid => $info) ;
$html = include(TEMPLATE_PATH . "/list.php");
endforeach; 
echo json_encode('data_arr'=>$html);
}

添加这段代码后,我没有得到任何结果。但是如果我给赋值$items">data_arr’然后我得到了结果。我想把这个PHP页面包含在for循环中。

function fn_nextitem(sliderNo){

$.get("/index.php?op=ajax", {slide_no:sliderNo},function(resp) {
if (resp) {


$('#Div').append(resp);
}
else {

} 
}
我的PHP代码是这样的:
if(!empty($items )){  
foreach ($items as $itemid => $info) ;
$html = include(TEMPLATE_PATH . "/list.php");
endforeach; 

}
在那之后,我得到了我想要的结果。

最新更新