I am trying to show a slideshow on a screen running a old version of Samsungs Hospitality Browser. the browser does not support fetch or promises so i have to use xmlhttprequest, the problem is i want to call the xmlhttprequest again when the slideshow is done. Currently it is called recursively, but that means the callstack never is cleared, so it's not really a sustainable fix.
xmlhttprequest:
function getData(url) {
var req = new XMLHttpRequest();
req.overrideMimeType("application/json");
req.open('GET', url, true);
req.onload = function () {
var jsonResponse = JSON.parse(req.responseText);
generateSlides(jsonResponse);
};
req.send();
}
the function showing the images and calling the xmlhttprequest recursively
function showPosters(slides, slideIndex) {
console.log(slideIndex);
setPoster(slides[slideIndex]);
slideIndex++;
if (slideIndex == slides.length + 1) {
getData("http://localhost:5000/Posters");
} else {
setTimeout(showPosters, 4000, slides, slideIndex);
}
}
Is there any way to wait until the callback is complete, when await and promises isn't supported?