Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Last active August 3, 2020 08:37
Show Gist options
  • Save BMU-Verlag/d8acb74ea5ce920ed179c524ad858051 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/d8acb74ea5ce920ed179c524ad858051 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>AJAX-Beispiel 1</title>
<script>
function laden() {
let ajaxObj = new XMLHttpRequest();
ajaxObj.onreadystatechange = ausgeben;
ajaxObj.open("GET", "daten.txt", true);
ajaxObj.send();
}
function ausgeben(){
if (this.readyState == 4 && this.status == 200) {
document.getElementById("ausgabe").innerHTML = this.responseText;
}
}
</script>
</head>
<body>
<h1>Nachrichten anzeigen</h1>
<textarea id="ausgabe" style = "height:150px; width:150px;">
</textarea><br><br>
<button type="button" onclick="laden()">Inhalt anzeigen</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment