I'm trying to use a PHP function to read a server directory for images. The images will then need to be passed back to JQuery using .ajax() for use in a slideshow. I'm using the PHP function hoping to simplify adding/removing images for my user. Basically, all they'd have to do is add or remove images from the directory to modify the slideshow and not edit any code.
I'm struggling to get the JQuery function to return what I'm expecting. It's been a while since I've done PHP so I may be overlooking someone. Here's my PHP code:
<?php
$path = "./";
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
echo "<img src=\"" . $path.$file. " alt=\"" . $file . "\>";
{
}
?>
Here's my readImages JQuery function:
function readImages() {
$.ajax({
type: "POST",
url: "getimages.php",
dataType: "html",
success: function(imagepath){
$(".slideshow").html(imagepath);
}
});
}
What I'm trying to do is get the PHP to return an HTML formatted tag with the file name added. The JQuery then adds the returned tag to the HTML code.
So far... all it's returning is "; { } ?>
Any ideas as to what I'm doing wrong?