<html>
<head>
<title>MY FIRST AJAX SCRIPT</title>
<script language = "javascript" type = "text/javascript">
function checkName()
{
var xml;
try
{
xml = new XMLHttpRequest();
}
catch(e1)
{
try
{
xml = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e2)
{
return false;
}
}
xml.onreadystatechange = function()
{
if(xml.readyState == 4)
{
alert(xml.responseText);
}
else
{
alert("An error occurred while retrieving file");
}
{
xml.open("GET", "http://localhost/ajax/file.xml",true);
xml.send(null);
}
</script>
</head>
<body>
<a href = "#" onclick = "checkName()">Click me!<a/>
</body>
</html>
When I click on the link nothing happens. Please help.