I'm building a page that has a (with bootstrap 4) carousel that displays some information about temperatures. This information comes from an XML that will be updated whenever a change occurs.
I'm doing the tests by manually changing the XML file, but I can not see the changes. I've already tried setTimeout
and setInterval
(the setInterval
repeats the entire HTML block) and can not see the changes, it seems that in the case of setTimeout
, it does not load the < in> XML again.
Could anyone help me to unravel this mystery? Thank you in advance for your attention:)
Code:
function temperatures() {
'use strict';
$.get('temperature.xml', function (data) {
$(data).find('temperature').each(function () {
let $temperature = $(this);
let type = $temperature.find('type').text();
let value = $temperature.find('value').text();
let temperatures = '<div class="carousel-item temperature">';
temperatures += '<span class="sensor-value">' + value + '</span>';
temperatures += '<span class="sensor-title">' + type + '</span>';
temperatures += '</div>';
$('.temperatures').append($(temperatures));
});
});
setTimeout(temperatures, 1000);
}
$(function () {
temperatures();
});