Git-Center/js/app.js
2013-10-02 14:47:25 +02:00

21 lines
682 B
JavaScript

window.addEventListener('load', function() {
var sections = document.querySelectorAll('section');
for (var i = 0; i < sections.length; i++) {
callRequest(sections[i].id);
}
});
function callRequest(section) {
var pre = document.querySelector('#' + section + ' pre');
pre.innerHTML = '<span class="loading">Loading ...</span>';
var xhr = new XMLHttpRequest();
xhr.open('POST', 'ajax.php');
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send('action=status&section=' + section);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {
pre.innerHTML = xhr.responseText;
}
};
}