Hey all, i just bought this book on Ajax because i am a complete noob at it, although i do know a little Java.
I just copied some code out of the book and when i tested it on my website i get errors saying that Access is denied for XMLHttpRequestObject.open
Here is my code i have so far:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ajax Test</title>
</head>
<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.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
<body>
<h1>Fetching data with Ajax</h1>
<form>
<input type="button" value="Display Message" onclick="getData('http://www.1stopupload.com/beta1/data.txt', 'targetDiv')" />
</form>
<div id="targetDiv">
<p>The fetched data will go here.</p>
</div>
</body>
</html>
__________________
Go Kirby! <(" . "<) (^" . "^) (>" . ")> Talkupation!
|