I am trying to make an ajax call to a php script that outputs images from a directory.
I have this as my php script:
<?php
$con = @mysqli_connect('myhost','myusername','myuserpass','myuserDB') or die('Could not connect to the database.'." ". __FILE__ ." ". __LINE__);
$photoFile = mysqli_query($con, 'select photoFile from photoInfo');
while ($p = mysqli_fetch_array($photoFile)){
echo '<img class="image" src='."../img/".$p['photoFile'].".jpeg />";
};
mysqli_close($con);
?>
And I'm trying to call it like this.
$(document).ready(function() {
$.ajax({
url: 'php/getImages.php',
method: 'get',
dataType: 'html'
}).done(function(data){
$('#imageBox').appendData(data);
});
});
What all am I doing wrong? When I run the php script on its own, it brings up the images but when I try to use ajax to call it, nothing happens.
srcand try.