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;
}
精彩评论