Caddy-Web-UI/static/js/main.js

35 lines
827 B
JavaScript
Raw Normal View History

2019-10-31 15:01:43 +00:00
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function loadSites(){
getJSON('http://localhost:8000/api/Sites',
function(err, data) {
if (err !== null) {
alert('Something went wrong: ' + err);
} else {
for (index = 0; index < Object.keys(data).length; index++) {
renderSite(data[index]);
}
}
}
);
}
function renderSite(site){
site = ``
console.log(site);
}