How can I delete the loaded data through a ajax
call so that when I press on another image the relative images are loaded?
This is my code for loading fancybox
:
$(document).ready(function () {
$("[data-fancybox]").fancybox({
loop: false,
closeExisting: true,
buttons: [
// "zoom",
//"share",
"slideShow",
// "fullScreen",
//"download",
// "thumbs",
"close"
],
onInit: function (instance) {
let id_album = $("[data-fancybox]").attr('id');
$.ajax({
type: 'POST',
url: './function/retrive-photo.php',
data: {
id_album: id_album
},
dataType: 'json',
success: function (data) {
$.each(data, function (index, item) {
instance.addContent({
'type': 'image',
'src': item.src
});
});
}
});
},
afterClose: function () {
$('.fancybox-content').remove();
console.log("DONE B!");
}
});
});
I try to delete the content of the fancybox
loaded via ajax
using the command $('.fancybox-content').remove()
but it doesn't work