Greetings evilzone members.
I was following this basic tutorial from a pdf book I downloaded and so far I understood what they are saying but my code somehow does not work. Here is the whole code of my page:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form method="GET">
<input type="button" onclick="Validate('test.txt','demo')" value="Click me" />
</form>
<span id="demo">I will display message here!</span>
<script>
var XMLHttpRequestObject = false;
if(window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
}
function Validate(path,divID) {
if(XMLHttpRequestObject) {
var object = document.getElementById(divID);
XMLHttpRequestObject.open("GET",path);
XMLHttpRequestObject.onreadystatechange = function() {
if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
object.innerHTML = XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
} else {
document.getElementById(divID).innerHTML = "Sorry, but Ajax is not enabled for your browser";
}
}
</script>
</body>
</html>