MeasurementTesting / static /MC_T_API_Worker.js
Marthee's picture
Update static/MC_T_API_Worker.js
dfa4a77 verified
intervalBegin()
function intervalBegin(){
// minutes= min *60*1000
intervalAPI= setInterval( getRefreshAPIAjax ,1800000) // 30*60*1000 // every 30 min
}
function getRefreshAPIAjax(){
ajax('/RetrieveMCTNames/')
.then(function(data) {
MCTNames=JSON.parse(data);
self.postMessage(MCTNames); // Code depending on result
})
}
function ajax(url) { //sectionData
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
resolve(this.responseText);
};
xhr.onerror = reject;
xhr.open('GET', url)//+'?jsdata=' + jsdata);
xhr.send();
});
}
/*Retrieve MCTNAMES Dictionary from API - Flask*/