Bug Tracker

Opened 14 years ago

Closed 12 years ago

Last modified 11 years ago

#4958 closed bug (fixed)

ajax methods fail in IE for content types ending in +xml

Reported by: jaffathecake Owned by:
Priority: low Milestone: 1.5
Component: ajax Version: 1.3.2
Keywords: xml, rss, ajaxrewrite Cc:
Blocked by: Blocking:


IE doesn't understand content types like application/rss+xml, responseXML contains an empty xml document.

To recreate, try and load an RSS file using jquery.get in IE 6 / 7. Ensure the RSS file is served as application/rss+xml.

As a workaround, you can create a new ActiveXObject("Microsoft.XMLDOM") and feed it the responseText.

Attachments (1)

ajaxxmlfix.patch (735 bytes) - added by jaffathecake 14 years ago.
Rough solution

Download all attachments as: .zip

Change History (14)

Changed 14 years ago by jaffathecake

Attachment: ajaxxmlfix.patch added

Rough solution

comment:1 Changed 14 years ago by jaffathecake

The patch above uses browser detection, not sure how you'd solve this via feature detection. Also, the bug doesn't occur in IE8, but giving it the fix does no harm.

comment:2 Changed 13 years ago by dmethvin

Closed dup #4975.

comment:3 Changed 13 years ago by zevspitz

You don't need to create a new XMLDOM object; you can use the existing one.
Also, As far as the browser-detection goes, why not just detect data.documentElement === null?

if ( xml ) {
    if (data.documentElement === null && data.parseError.errorCode === 0) {
    if ( data.documentElement.nodeName === 'parsererror' ) {

There is an additional check, for the parseError.errorcode: If the responseText could not be parsed as XML the first time, there is no point in trying it agasin.

comment:4 Changed 13 years ago by zevspitz

This would also be relevant to #2949

comment:5 Changed 13 years ago by zevspitz

An additional note: for browsers which don't support parseError, an error will be trapped by the calling function

comment:6 Changed 12 years ago by addyosmani

#2109 is a duplicate of this ticket.

comment:7 Changed 12 years ago by SlexAxton

Milestone: 1.41.5
Priority: majorlow
Status: newopen

comment:8 Changed 12 years ago by Rick Waldron

Keywords: ajaxrewrite added

comment:9 Changed 12 years ago by jaubourg

Resolution: fixed
Status: openclosed

The new ajax implementation will do the parsing automatically.

comment:10 Changed 11 years ago by SeanH

This is not fixed correctly and it needs additional checks apart from documentElement to distinguish a HTML Dom object from an XML Dom object.

There is a bug in IE 10 (10.0.8400.0), the version included in the windows 8 preview release, that shows that the check was not adequate. In this release no correctly set xml mime type is parsed as xml, instead it is parsed as html. This results in all code relying on jQuery.ajax calls using the dataType xml and content type "text/xml” failing.

My suggestion is the following:

Modify the check for xml to (+-line7889)

if ( xml && xml.documentElement && !xml.forms/* #4958 */ ) {

HTML Dom will have .forms XML Dom will not.

Add an extra converter in jQuery.ajaxSetup for text -> xml. (+-line7771)

"text xml": function (text){
	var xml = jQuery.parseXML(text);
	return xml;

comment:11 Changed 11 years ago by jaubourg


Have you tried to report the bug to the IE team? It's obviously a problem on their end and I'd like to see if we could have this fixed in IE10 before hacking in jQuery.

Also, I don't really see why you redefine the converter while it's already set to parseXML: https://github.com/jquery/jquery/blob/master/src/ajax.js#L358

comment:12 Changed 11 years ago by SeanH

I am going to report the bug to the IE team as well, but since I have investigated this I decided to post here first. I still believe an extra check is required on that line of code regardless if the IE team fixes / doesn't fix the issue.

As to your second question I redefined it simply because I didn't see that code and our code was wasn't working still.

I have found out why it wasn't working. We redefined the parseXML function and the code uses your internal one instead of ours.

We have horrible browser detection code that ensures the xml object returned as the selectSingle node method. We had to extend this for IE 10. Our code heavily relies on this method and we have not written a replacement yet for when IE uses the DOMParser.

(function($) {
	$.parseXML = function( data ) 
		var xml, tmp;
			if (!($.browser.msie && ($.browser.version == 9 || $.browser.version == 10)) && window.DOMParser ) 
			{ // Standard
				tmp = new DOMParser();
				xml = tmp.parseFromString( data , "text/xml" );
			{ // IE
				xml = new ActiveXObject( "Microsoft.XMLDOM" );
				xml.async = "false";
				xml.preserveWhiteSpace = true;
				xml.loadXML( data );
		catch( e ) 
			xml = undefined;
		if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) 
				if (data.toString)
					jQuery.error( "Invalid XML: " + data );
			catch (e)
				jQuery.error('Invalid XML (cannot represent object as string).');
		return xml;


Note: See TracTickets for help on using tickets.