开发者

w3C answer not work for loading XML in IE

开发者 https://www.devze.com 2023-03-22 09:24 出处:网络
I want to load a XML file in IE 7/8 and I search the answer from the w3c. I found the answer, the following code, but when I use the javascript to do that, it shows \'Access is denied\' error to my js

I want to load a XML file in IE 7/8 and I search the answer from the w3c. I found the answer, the following code, but when I use the javascript to do that, it shows 'Access is denied' error to my js file. Can anyone help me?

w3c li开发者_如何学JAVAnk: Example

<script type="text/javascript">

function loadXML(location) {

if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else // for IE 5/6
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",location,false);        // error in here, even I type the link here, also not work
xhttp.send();
xmlDoc=xhttp.responseXML;
}
</script>


Older versions of IE does not support responseXML here is what you do:

if (window.ActiveXObject) {
   var response = xhttp.responseText;

   var XMLdoc = new ActiveXObject("Microsoft.XMLDOM");
   XMLdoc.loadXML(http_request.responseText);
}else {
   var XMLdoc = http_request.responseXML;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消