If you're interested, I have some code available on JS Fiddle that showcases my skills.
var getJSON = function (url) {
"use strict";
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
resolve(xhr.response);
} else {
reject(status);
}
};
xhr.send();
});
};
function updateCount() {
"use strict";
getJSON('http://192.99.124.166:8080/count').then(function(data) {
console.log('update');
stats.innerText = data.result; //display the result in an HTML element
});
}
updateCount();
setInterval(updateCount, 10000);
If you check out this code on Chrome, Opera or Microsoft Edge, you'll see server and player stats automatically updating every 10 seconds as intended. However, when viewed on IE 11 or Firefox, the div that should display results remains empty.
I'm not a JavaScript expert, and though I received help from someone via IRC to improve the code using JS Lint and implementing "use strict," the issue persists on IE 11 and Firefox.
If anyone could provide insight into why this might be happening, I'd greatly appreciate it. I've tried inspecting the code on IE 11 and Firefox but nothing seems to trigger or show up. Oddly enough, even though the browser console displays the "update" message, the div doesn't display anything!