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

1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by cossay
1

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

Votes + Comments
Good. Found the error and you written here then marked solved..
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.