2013-10-02 10:21:30 +00:00
|
|
|
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");
|
2013-10-02 12:27:20 +00:00
|
|
|
xhr.send('action=status§ion=' + section);
|
2013-10-02 10:21:30 +00:00
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {
|
2013-10-02 12:47:25 +00:00
|
|
|
pre.innerHTML = xhr.responseText;
|
2013-10-02 10:21:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|