Better interface, loading icon
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user