MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Nerdberg
Wechseln zu:Navigation, Suche
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 5: Zeile 5:
     if (xhr.status === 200) {
     if (xhr.status === 200) {
     json = JSON.parse(xhr.responseText);
     json = JSON.parse(xhr.responseText);
    
     document.getElementById("doorstatus").innerHTML = json.results[0].status;
var para = document.createElement("p");
var node = document.createTextNode(json.results[0].status);
para.appendChild(node);
 
var parent = document.getElementById("doorstatus");
var child = document.getElementById("p1");
parent.replaceChild(para, child);
     }
     }
};
};
xhr.send();
xhr.send();

Version vom 6. Oktober 2019, 19:50 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://doorstatus.nerdberg.de/api/doorstatus/');
xhr.onload = function() {
    if (xhr.status === 200) {
    	json = JSON.parse(xhr.responseText);
    	document.getElementById("doorstatus").innerHTML = json.results[0].status;
    }
};
xhr.send();