Übersichtshalber mal alle Dokumente:
script.js
function fireRequest(){
var ajax = null;
if(window.XMLHttpRequest){
ajax = new XMLHttpRequest();
}
else if(window.ActiveXObject){
http = new ActiveXObject("Microsoft.XMLHTTP");
}
if(ajax){
ajax.open('GET','test.txt',true);
ajax.onreadystatechange = function () {
if (this.readyState == 4) {
alert(this.responseText);
}
}
ajax.send(null);
}
test.txt:
Das ist der Testinhalt.
index.htm
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<button onclick="fireRequest();">
</body>
</html>
MfG
bubble