Skip to main content

Bug Tracker

Side navigation

#1111 closed bug (invalid)

Opened April 07, 2007 02:34PM UTC

Closed July 15, 2007 03:13PM UTC

IE7 bug for $(expr, context) ;

Reported by: geekinabox Owned by:
Priority: major Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:
Description

This barebones fails in my IE7:

var html1 = "<result>test</result> " ;
$("result",html1).text() ;

... IE informs me that "object doesn't support this property or method" on the selector ... it doesn't like the 'html1' context (or any context).

Something like this works (IOW, no error), but obviously doesn't fit the bill:

var html1 = "<result>test</result> " ;
$("result").text() ;

...sorry if this is a repeat ... i looked @ prev tickets.

Attachments (0)
Change History (4)

Changed April 07, 2007 05:42PM UTC by john comment:1

resolution: → worksforme
status: newclosed

I'm not really sure what you're trying to achieve, considering that <result> is not valid HTML nor is HTML a valid context. If I had to guess as to why an error was occurring, it's because you have an extra space at the end of your string (jQuery is only designed to work with elements - anything else will cause an error). In the end, however, your query won't match any results since the result element isn't a child of itself.

I think this is what you might be trying to achieve (but I'm not entirely certain:

  $(html1).text();

that should give you "test" as a result.

Changed April 09, 2007 01:28PM UTC by geekinabox comment:2

resolution: worksforme
status: closedreopened

Replying to [comment:1 john]:

john ... sorry if I didn't give enough detail/intent ... I was trying to keep it simple. My specific situation is that I have XML being returned from an ajax call. I want to parse that xml for a particular result. (obviously, then, I'm not dealing w/ html elements here).

Here's a revised example that, again, works in firefox, but not IE ...

	var xmldata = "<result><success>true</sucess><message>test</message></result>" ;
	alert($("result message",xmldata).text()) ;

The intent, to be clear, is the find the message element and output its content text.

Am I wrong in expecting this to work? Are jquery selectors for html docs/elements only, or are other XML docs valid targets, too? Am I correct in thinking that I should be able to target this random XML blob with a selector? Again, the fact that it works in firefox makes me thing I'm not crazy here, but maybe that's just a lucky coincidence (i.e., it works, but not by design).

The fact that the jquery documentation for '$( expr, context )' contains this comparable example (selecting against a XML doc):

$("div", xml.responseXML)

... makes me think that this ''should'' work.

I'll reopen this one last time ... if I'm off-base let me know and I'll let it go.

Thanks.

(I'm also experiencing this on IE6 on a separate machine)

Changed April 09, 2007 04:55PM UTC by geekinabox comment:3

Replying to [comment:2 geekinabox]:

(pardon the typ0 in the XML) ... fixed in and problems remains:

	var xmldata = "<result><success>true</success><message>test</message></result>" ;
	alert($("result message",xmldata).text()) ;

Changed July 15, 2007 03:13PM UTC by john comment:4

description: This barebones fails in my IE7:\ \ {{{\ var html1 = "<result>test</result> " ;\ $("result",html1).text() ;\ }}}\ \ ... IE informs me that "object doesn't support this property or method" on the selector ... it doesn't like the 'html1' context (or any context).\ \ Something like this works (IOW, no error), but obviously doesn't fit the bill:\ {{{\ var html1 = "<result>test</result> " ;\ $("result").text() ;\ }}}\ \ ...sorry if this is a repeat ... i looked @ prev tickets.This barebones fails in my IE7: \ \ {{{ \ var html1 = "<result>test</result> " ; \ $("result",html1).text() ; \ }}} \ \ ... IE informs me that "object doesn't support this property or method" on the selector ... it doesn't like the 'html1' context (or any context). \ \ Something like this works (IOW, no error), but obviously doesn't fit the bill: \ {{{ \ var html1 = "<result>test</result> " ; \ $("result").text() ; \ }}} \ \ ...sorry if this is a repeat ... i looked @ prev tickets.
milestone: 1.1.31.1.4
resolution: → invalid
status: reopenedclosed
version: 1.1.21.1.3

The problem is that jQuery doesn't provide any mechanisms for parsing XML; xml.responseXML is actually a DOM Document (already pre-parsed) which is why we can handle it. Sorry for the confusion.