我想获取文件列表(来自名为uploads
.
获取文件.php
<?php
$dir = 'uploads/';
$a = scandir($dir);
$b=count($a);
for($x=2;$x<$b;$x++)
{
echo"<div class='filePass'>";
echo $a[$x];
echo "</div>";
}
?>
get_files.php
单独工作效果很好,即它正确列出了文件。
但我怎样才能得到里面的列表insideT
div ?
我可以包括get-files.php
但我需要使用 jquery ajax 来执行此操作,因为稍后会重用该函数。
function get_files(){
$.ajax({
url : 'get_files.php',
type : 'get'
});
$('#insideT').html(//here I want to get the file listing);
}
get_files();
Try this
获取文件.php
<?php
$dir = 'uploads/';
$a = scandir($dir);
$b=count($a);
$res = '';
for($x=2;$x<$b;$x++)
{
$res.= "<div class='filePass'>";
$res.= $a[$x];
$res.= "</div>";
}
echo $res;
?>
阿贾克斯脚本
function get_files(){
$.ajax({
type: "GET",
url: "get_files.php",
cache: false,
success: function(result){
$("#insideT").html(result);
}
});
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)