0

I'm using Jquery 1.9.1. It works fine in Chrome, but Ie 8, i get error: "invalid xml". It seems IE 6-8 has problems with dataType: xml. Jquery.parseXML is not working on ie-6-8.

$(document).ready(function() {
    $.ajax({
        type: "GET",
        url: "faculty.xml",
        dataType: "text",
        success: function(xml) { parseXmlx(xml); },
        error: function(e) { alert(e) }
    });
    $("#output").append("<p>Loading full-time faculty...</p>");
});

function parseXmlx(xml) {
    $("#output").empty();
    // alert(xml);
    var $xml = $(jQuery.parseXML(xml));
    // find every Tutorial and print the author
}



<person>
<name>test</name>
</person>

error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
Timestamp: Wed, 19 Jun 2013 17:42:26 UTC


Message: Invalid XML: <person>
<name>Test</name>
</person>

Line: 507
Char: 3
Code: 0
URI: jquery-1.9.1.js
runners3431
  • 1,425
  • 1
  • 13
  • 30

1 Answers1

0

I'm not sure if this is the problem causing the issue, but it's good practise to add following line as the first line of your XML file. (don't have access to IE8 to test this)

<?xml version="1.0" encoding="utf-8"?>

you could also try forcing the headers to make sure these are correct:

change

$.ajax({
    type: "GET",
    url: "faculty.xml",
    dataType: "text",
    success: function(xml) { parseXmlx(xml); },
    error: function(e) { alert(e) }
});

to:

$.ajax({
    type: "GET",
    url: "faculty.xml",
    dataType: ($.browser.msie) ? "text" : "xml",
    accepts: {
         xml: "text/xml",
         text: "text/xml"
    },
    success: function(xml) { parseXmlx(xml); },
    error: function(e) { alert(e) }
});

(cfr. IE9 refuses to process XML response )

Community
  • 1
  • 1
Kristof Feys
  • 1,822
  • 1
  • 19
  • 36