-
-
Save wolfkarl/5948529 to your computer and use it in GitHub Desktop.
simple ajax request --> alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Request Objekt Anlegen | |
var httpRequest; | |
if (window.XMLHttpRequest) { // Mozilla, Safari, ... | |
httpRequest = new XMLHttpRequest(); | |
} else if (window.ActiveXObject) { // IE 8 and older | |
httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
// funktion erstellen, die aufgerufen wird wenn | |
// das req.o. request abschliesst | |
httpRequest.onreadystatechange = function(){ | |
if (httpRequest.readyState === 4) | |
{ | |
// http Request vollstaendig abgewickelt | |
if (httpRequest.status === 200) | |
{ | |
alert(httpRequest.responseText); | |
} | |
else | |
{ | |
alert("error!"); | |
} | |
} | |
}; | |
httpRequest.open('GET', 'async.php', true); | |
httpRequest.send(null); | |
// (nun wird die Funktion oben aufgerufen!) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment