Bug Tracker

Ticket #1850 (closed bug: invalid)

Opened 7 years ago

Last modified 5 years ago

JQuery DOM does not work in IE

Reported by: seawater Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: IE DOM Cc:
Blocking: Blocked by:

Description

I have the following simple code which works in FF, but not in IE

var domStr = '<test><letters id="id1">abcd</letters><letters id="id2">efgh</letters></test>'; from server-side through AJAX

var xml = $(domStr);

var quote = $(xml).find('letters#id1');

alert(quote.html());

Looks to me jquery in IE not work with DOM created by fly.

Change History

comment:1 Changed 7 years ago by seawater

I have the following simple code which works in FF, but not in IE

var domStr = '<test><letters id="id1">abcd</letters><letters id="id2">efgh</letters></test>'; from server-side through AJAX

var xml = $(domStr);

var quote = $(xml).find('letters#id1');

alert(quote.html());

Looks to me jquery in IE not work with DOM created by fly.

Error Message is:

Line: 1363 Character: 8 Code: 0 Error Message: Object doesn't support this property or method URL

Jquery version is jQuery 1.2.1

comment:2 Changed 7 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone changed from 1.2.1 to 1.2.2

jQuery lets you do some things with XML but creating an XML document is not one of them. So what you are doing with

var xml = $(domStr);

is to create a non-standard HTML DOM fragment. This works a little big in some browsers like FF but not at all in IE (as you noticed). At this point, that is a feature that is not implemented so this ticket is invalid.

But you did mention the XML text was received from AJAX. In that case, assuming you have the correct data types set, the XML document will be returned in your success function so:

$.ajax({ 
    url:"data.xml", 
    success:function(xml){
          // xml is the xml document
        }
});

Then you can do your $(xml).find(...);

comment:3 Changed 5 years ago by xiarugu

sometimes, we want to get html() of one xml node. even DOM is not implemented to create in all browsers. but at least, we can just get the html() value. my change is add these code under jquery lib.

jQuery.fn.html=function( value ) {

return value === undefined ?

(this[0] ?

(this[0].innerHTML?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, ""):(this[0].childNodes.length?this[0].xml.replace(/<[<>]+>(.*)<[<>]+>$/g,"$1"):"")) : null) :

this.empty().append( value );

},

Note: See TracTickets for help on using tickets.