Better interface, loading icon

This commit is contained in:
Thomas Forgione
2017-09-25 17:17:24 +02:00
parent 5e63027352
commit 944ba2fb03
4 changed files with 49 additions and 5 deletions

View File

@@ -1,9 +1,13 @@
let loadingDiv = document.getElementById('loading');
let errorDiv = document.getElementById('error');
let resultDiv = document.getElementById('result');
const timeout = 30000;
const timeout = 10000;
function getTable() {
// Send XHR to totalTable
loadingDiv.style.display = "";
errorDiv.style.display = "none";
let xhr = new XMLHttpRequest();
xhr.timeout = timeout;
xhr.onreadystatechange = function() {
@@ -17,17 +21,18 @@ function getTable() {
};
xhr.open('GET', '/total-table', true);
xhr.send();
window.xhr = xhr;
}
function setData(text) {
loadingDiv.style.display = "none";
errorDiv.style.display = "none";
resultDiv.innerHTML = text;
}
function setError() {
loadingDiv.style.display = "none";
resultDiv.innerHTML = "An error occured";
errorDiv.style.display = "";
}
document.getElementById('tryAgain').addEventListener('click', getTable);
getTable();