Hi all,
I am trying to create a web page that reads a web service which presents a page in XML - (you go to a URL with the right parameters in the querystring and get a page of XML). I will eventually apply transformations on the XML to give a nice looking page, but for now I am having trouble just reading the data.
The error I get is:
In FireFox:
Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]
In IE:
Access is denied.
I know the XML page works - I can see it in the browser.
I know it is accessible to web site I am adding the page to as I built a Flex app to read it previously from the same location.
So the error must be my code.
And here is the code:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XML</title>
<script language="javascript" type="text/javascript">
function xmlCall()
{
var xmlDoc;
var xmlhttp;
var url = "";
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
try
{
xmlhttp=new ActiveXObject("MSXML2.ServerXMLHTTP");
}
catch (e) {}
try
{
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP.6.0");
}
catch (e) {}
try
{
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
catch (e) {}
try
{
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
}
catch (e) {}
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
throw new Error("This browser does not support XMLHttpRequest.");
}
xmlhttp.open("GET",url,false);
try
{
xmlhttp.send();
}
catch (e) { alert(e.message); };
xmlDoc = xmlhttp.responseXml;
}
</script>
</head>
<body onload="xmlCall();">
</body>
</html>
I know url is blank - the web service is not yet public so I can’t publish the URL - but I would guess this should work with any XML page.
I have looked around for answers without luck, any help is appreciated.