PHP's scandir with ajax call
I have some content loaded via ajax that includes the scandir() function. On local and on my server it works perfectly, however on my client's server it didn't work because they run PHP4 (scandir() was implemented in version 5). I called tech support and their solution was to change file extensions from .php to .php5. However, this only partially works if I call directly the page, but when I load it via ajax it does not.
Is there a way to fix this? I didn't know ajax and PHP could be incompatible.
EDIT
Here's part of the code. Is simply an image gallery and I'm using scandir() to get the images:
<div id="#vtabs-content-a"> <ul class="slider"> <?php $featured_dir = 'img/systems/6020/'; $scan = scandir($featured_dir); echo '<li id="' . $scan[2] . '"><img src="' . $featured_dir . $scan[2] . '" alt="' . $scan[2] . '" width="700" height="350" /></li>'; ?> </ul> <ul class="thumb 6020a"> <?php $dir = 'img/systems/6020/z_thumbs/'; $scan = scandir($dir); for ($i = 0; $i<count($scan); $i++) { if ($scan[$i] != '.' && $scan[$i] != '..') { echo '<li><a href="#' . $featured_dir . $scan[$i] . '"><img src="' . $dir . $scan[$i] . '" alt="' . $scan[$i] . '" width="40" height="40" /></a></li>'; } }; ?> </ul>
I actually had forgotten to change to .php5 in the ajax call, already did it but still won't work. Another point is that when I call the page directly the slideshow doesn't work, but at least the pictures are there.
The ajax call is this:
$(".a6020").live("click", function(){ $("#main").load("a6020.php5 #container", function(){ $('#vtabs5').jVertTabs(); $.getScript("js/scandir.js", function(){ }); }); });
Answers
You could try adding a .htaccess file to run php5 on extensions that end in .php by adding
AddHandler application/x-httpd-php5 .php
To a .htaccess file.