Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag

BMU-Verlag/ajax_1_4.html

Last active Aug 3, 2020
Embed
What would you like to do?
<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