jQuery, AJAX and Internet Explorer

The issue:
Internet Explorer won’t parse XML quite as easily as every other browser on the internet (I assume). You have to change what you pass it as through jQuery. In IE it has to be passed as text, while the rest can handle it as XML. You also have to pass it through a separate function that brings in ActiveX before you can navigate your way through the XML and use it in your application.

The solution:
Set the type to “text” for IE and “xml” for the rest.

<code>$.ajax({
    type: 'GET',
    url: 'sample.xml', // your xml file
    dataType: ($.browser.msie) ? &quot;text&quot; : &quot;xml&quot;, // text for IE, xml for the rest
    success: function(xml) {
        var newXML = parseXml(xml);
        // and then process normally
    }, // end success
    error: function(a, b, c) {
      alert('error'); // this is where the errors happen, 'b' and 'c' are typically the only ones with values
    } // end error
  }); // end .ajax

function parseXml(xml) {
  if (jQuery.browser.msie) {
    var xmlDoc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);
    xmlDoc.loadXML(xml);
    xml = xmlDoc;
  }
  return xml;
}</code><a href="http://codepen.io/jeremyHixon/pen/HjFKk">Check out this Pen!</a>


Reference the function in your .ajax()

success: function(xml) {
  var newXML = parseXml(xml);
  $(newXML).find()....

And…voila!