I have made a media gallery for website where i am using images from previous uploads. but i have created multiple folder in my media/ folder like gallery-images, hotel-images etc.
now i want to refresh a particular div where i upload a image like if i upload file in hotel-images, then refresh only hotel-images display tab div
Here is my code :
<h4 class="md-total-img">Total
<?php
echo $fol = $_POST['val'];
$filecount = 0;
$file = glob("$fol/*.*");
if ($file){
$filecount = count($file);
}
echo "($filecount) files";
?>
</h4>
<div class="md-search-img">
<button id="MyButton" data-name="<?php echo $fol; ?>" class="btn btn-warning">Refresh</button>
</div>
Here is Javascript:
$(document).ready(function(){
$('#MyButton').on('click', function() {
var ref_folder = $(this).attr("data-name");
alert(ref_folder);
$.ajax({
type:"POST",
url: "media/media-ajax.php",
data:{val:ref_folder},
cache: false
})
.done(function( html ) {
if(ref_folder == 'hotels'){
$( "#hotelsview" ).html( html );
alert(ref_folder);
}
if(ref_folder == 'gallery'){
$( "#galleryview" ).html( html );
alert(ref_folder);
}
});
});
Can anyone help me to do like this ?