Every 2 seconds I update a table on my page. This table has a Modal button that also contains information and therefore it is also updated every 2 seconds. The problem is that the info in the Modal doesn't load after using clear Interval. (No need to say that I do need to use clear Interval because Modal doesn't work with the table updating constantly). The code is as follow
var myTimer;
function startTimer() {
myTimer = setInterval(function () {
somefunction_to_updatetable();
}, 2000);
};
function stopTimer() {
clearInterval(myTimer);
};
$(document).on('show.bs.modal', '#idModal', function (e) {
stopTimer();
});
window.onload = function() {
startTimer();
};
In this code, when loading the page setInterval is defined with window.onload. It starts updating info in the table every 2 seconds. When I click the Modal button, stopTimer is read and setInterval is cleared. The Modal opens but the info is not there, only info that is not part of somefunction_to_updatetable() is present in the Modal... how can I fix this? I feel it is straightforward from where I am but I really cannot find a way