开发者

Ajax script will not load PHP read dir script?

I have a simple ajax script from javascriptkit.com that loads and external page into a div. When I stick my PHP read directory script in there it does not work. Is this something that can even be accomplished? Below is the ajax....

<head>
<script type="text/javascript" src="ajaxpagefetcher.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<div id="demo" style="border: 1px dashed gray; width: 300px; height: 200px; padding: 3px;    
background: none repeat scroll 0% 0% lightyellow;"></div>
<a href="javascript:ajaxpagefetcher.load('demo', 'PHP SCRIPT HERE', false)">Load Content 1</a>
</body>

Here is the PHP that I am using.

 <?php

  // These files will be ignored
  $excludedFiles = array (
'excludeMe.file',
'excludeMeAs.well'
  );

  // These file extensions will be ignored
  $excludedExtensions = array (
   'html',
'xslt',
    'htm',
'ahk',
'xsl',
'txt',
 'xml'
  );

// Make sure we ignore . and ..
$excludedFiles = array_merge($excludedFiles,array('.','..')); 

// Convert to lower case so we are not case-sensitive
for ($i = 0; isset($excludedFiles[$i]); $i++) $excludedFiles[$i] =    
strtolower(ltrim($excludedFiles[$i],'.'));
for ($i = 0; isset($excludedExtensions[$i]); $i++) $excludedExtensions[$i] =     
strtolower($excludedExtensions[$i]);

// Loop through directory
$dir = 'dir/dir/';
if ($handle = opendir($dir)) {

while (false !== ($file = readdir($hand开发者_开发问答le))) {
  $extn = explode('.',$file);
  $extn = array_pop($extn);
  // Only echo links for files that don't match our rules
  if (!in_array(strtolower($file),$excludedFiles) &&      
  !in_array(strtolower($extn),$excludedExtensions)) {
    $count++;
    print("<a href=\"".$dir.$file."\">".$file."</a><br />\n");
  }
}
 echo '<br />';
closedir($handle);
 }

 ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜