<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.

I found where the problem was coming from. It's on line 34. I used "{" instead of "}"

commented: Good. Found the error and you written here then marked solved.. +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.