My current JS loads images on a page that are locally stored (below),
**I want them to load in the webpage from a .txt file instead.
JS
[code]
var xhr = new XMLHttpRequest();
xhr.open(“GET”, “files/img”, true);
xhr.responseType = ‘document’;
xhr.onload = () => {
if (xhr.status === 200) {
var elements = xhr.response.getElementsByTagName(“a”);
for (x of elements) {
if ( x.href.match(/.(jpe?g|png|gif)$/) ) {
let img = document.createElement(“img”);
img.setAttribute(“id”, “galleryImg”);
img.classList.add(“w-100”)
img.classList.add(“container”)
img.src = x.href;
document.body.appendChild(img);
}
};
}
else {
alert(‘Request failed. Returned status of ‘ + xhr.status);
}
}
xhr.send()