I have an html file that calls a javascript/AJAX file which calls an ASP page. the ASP only generates the current year, then returns it to AJAX, then this should return it to the html page... and it's not... can some see what it is I am doing wrong? When I put the javascript/ajax in the actual html code it works... however for the application I am building this is NOT an option that is available to me
html file:
ajax file:
html file:
Code:
<head>
<title>Copyright Year Example AJAX</title>
<script type="text/javascript" src="CopyrightYear.js"></script>
</head>
<body onload="ajaxFunction()">
1997-<div id="CopyrightYearid" /> <br />
1997-<span id= "CopyrightYearid" /> <br />
</body>
</html>
ajax file:
Code:
// JScript File
<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.CopyrightYearid.value=xmlHttp.responseText;
CopyrightYearid.value=xmlHttp.responseText;
//document.myForm.CopyrightYearid.value=xmlHttp.responseText;
}
}
xmlHttp.open("GET","CopyrightYear.asp",true);
xmlHttp.send(null);
}
</script>