i'm creating a gallery which is loaded from a directory. first im creating a div tag for each album folder in the directory. then im using jquery ajax to get the folder name that was clicked and create div tags for each image in that folder. im sending the id of the folder to an external php page to grab the file paths for the images. im not sure how to output actual html. quite new to ajax/php coding so explanations are helpful.
jquery ajax:
var jq=$.noConflict();
jq(document).ready(function(){
jq(".album-select").click(function(event){
var id=event.target.id;
jq.ajax({
type: "POST",
url: "image_loader.php",
data: {phpid:id},
success: function(data){
jq('#mydiv').html("");
jq('#mydiv').append(data);
}
});
image_loader.php
if (isset($_POST['phpid'])) {
$album_fill = $_POST['phpid'];
}
$dir = 'images';
$slash = '/';
$dir_image = "$dir$slash$album_fill";
$dir_contents = scandir($dir_image);
foreach($dir_contents as $file){
if($file !== '.' && $file !== '..'){
$dir_imagepath = "$dir_image$slash$file";
echo '
echo '';
echo '
}}?>