Skip to main content

Bug Tracker

Side navigation

#1850 closed bug (invalid)

Opened October 26, 2007 09:12PM UTC

Closed December 04, 2007 10:19PM UTC

Last modified March 26, 2009 03:07AM UTC

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:
Blocked by: Blocking:
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.

Attachments (0)
Change History (3)

Changed October 26, 2007 09:18PM UTC by seawater comment:1

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

Changed December 04, 2007 10:19PM UTC by davidserduke comment:2

milestone: 1.2.11.2.2
resolution: → invalid
status: newclosed

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(...);

Changed March 26, 2009 03:07AM UTC by xiarugu comment:3

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 );

},