I have the following black of code which is working perfectly fine on Chrome & Firefox but fails everytime on IE, it returns "undefined" in the console tab.
<html>
<head>
<script type="text/javascript" charset="utf-8" src="/js/jquery-latest.js"></script>
<script>
$(document).ready(function()
{
test();
});
function test()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","/xml/products.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var list = xmlDoc.getElementsByTagName("product");
console.log(list[0].childNodes[1].innerHTML);
}
</script>
</head>
</html>
The XML i'm using is the following :
Thanks for your time.
EDIT: jQuery ajax version not working either:
var xmlDoc;
$.ajax({
type: "GET",
url: "/xml/products.xml",
dataType: "xml",
success: function (xml) {
xmlDoc = xml;
var list=xmlDoc.getElementsByTagName("product");
console.log(list[1].childNodes[1].innerHTML );
}
});
$.ajax(), you seem to already have jQuery. It levels a LOT of cross-browser quirks, especially with vendor low-level APIs as this!async=falsehave something to do with CORS? Am I missing something? Those two aspects are totally unrelated in my book...