Hello,
I am new to AJAX and I got the dummy book and tried the first example but it is failing, I was hoping you would be able to help me.
Thanks
I am not getting an error code for the script it is just not working...
Thanks again.
I am new to AJAX and I got the dummy book and tried the first example but it is failing, I was hoping you would be able to help me.
Thanks
Code:
<html>
<head>
<title> Ajax Test</title>
<script language="javascript">
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest){
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
function getData(dataSource, divID)
{
if(XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open("GET", dataSource);
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
obj.innerHTML = XMLHttpRequestObject.resposeText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
</head>
<body>
<h1>Fetching Data with Ajax</h1>
<form>
<input type="button" value="Display Message" onclick="getData('[URL unfurl="true"]http://localhost/AJAX/data.txt'),[/URL] 'targetDiv');" />
</form>
<div id="targetDiv">
<p>
The Fetched Data will go here.
</p>
</div>
</body>
</html>
Thanks again.