0

Hi,
I'm trying to load some xml in using ajax. But my xmlhttp status is always 0.

The status never comes through as 200.
I dont actually no what 0 is equal to. I could find anything when I looked that status up.
My script looks like this...

Could someone tell me where am going wrong

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function loadXMLDoc(){
	var xmlhttp;
	var txt,x,xx,i;
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		xmlhttp.onreadystatechange = xmlhttpChange;
		xmlhttp.open("GET", "http://www.w3schools.com/ajax/cd_catalog.xml", true);
		xmlhttp.send();	
	}else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	function xmlhttpChange(){
		if (xmlhttp.readyState == 4) {
			alert(xmlhttp.status)
			if (xmlhttp.status == 200) {
				alert("fine")
			}
		}
	}
}
loadXMLDoc();
</script>
</head>
<body>
</body>
</html>
1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by aidanmack
This topic has been dead for over six months. 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.