React
This commit is contained in:
2021-01-18 17:15:07 +01:00
parent 5654a4c0df
commit 9703181abd
102 changed files with 23758 additions and 0 deletions
@@ -0,0 +1,31 @@
xhrCurrent = new XMLHttpRequest();
url = 'http://localhost:8000/searches';
xhrCurrent.open("POST", url, true);
xhrCurrent.setRequestHeader('Access-Control-Allow-Methods', 'POST');
xhrCurrent.setRequestHeader("Content-Type", "application/json");
xhrCurrent.onerror = function () {
alert("Fehler");
}
xhrCurrent.onreadystatechange = function () {
if (xhrCurrent.readyState === 4 && xhrCurrent.status === 200) {
var parent = document.getElementById("currentSearch");
var child = parent.lastElementChild;
while (child) {
parent.removeChild(child);
child = parent.lastElementChild;
}
var textField = document.createElement("p");
var json = JSON.parse(xhrCurrent.response);
var output = json.Search;
textField.innerHTML = output;
document.getElementById("currentSearch").appendChild(textField);
}
};
// Converting JSON data to string
var data = JSON.stringify({ "Search": "current" });
// Sending data with the request
xhrCurrent.send(data);