What I am trying to do is load all the files(images) from the directory and append every image on the slick slider. I initialize the slider on document ready in js file and after initialization I call the function addImagestoSlider(). This works when I test the site locally(the images are displayed), but when I convert it to bolt cms the images doesn't show in the slider. I can see the images in the inspect element, but they are not displaying.
The javascript function:
function addImagesToSlider() {
console.log("in addImagesToSlider");
var dirCars = "http://localhost/bolt/public/bolt/files/files/Cars";
const fileextension = ".jpg";
$.ajax({
//This will retrieve the contents of the folder if the folder is configured as 'browsable'
url: dirCars,
success: function success(data) {
//List all .jpg file names in the page
$(data).find("a:contains(" + fileextension + ")").each(function() {
let filename = this.href.replace(window.location.host, "").replace("http://", "");
console.log("filename: " + filename);
$('#cars_slider .slide-tracker').append(`
<figure>
<img src="${filename}"
</figure>
`);
});
}
});
}