Jump to content

Ajax Not Responding


Chikwado
 Share

Recommended Posts

Hello, the xmlhttp.onreadystatechange=function() {} line is an anonymous function assigned to xmlhttp.onreadystatechange, that means that it should have an semicolon to end the expression, or a new line.

<!DOCTYPE html><html><head><script>function loadXMLDoc(){	var xmlhttp;	if(window.XMLHttpRequest)	{		xmlhttp=new XMLHttpRequest();	}		else	{		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");	}	xmlhttp.onreadystatechange=function()	{		if(xmlhttp.readyState==4 && xmlhttp.status==200)		{			document.getElementById("divpage").innerHTML = xmlhttp.responseText;		}	};	xmlhttp.open("GET","ajax.txt",true);	xmlhttp.send();}</script></head><body><div id="divpage"></div><button onclick="loadXMLDoc()">Get ajax</button></body></html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...