Bug Tracker

Modify

Ticket #1111 (closed bug: invalid)

Opened 6 years ago

Last modified 6 years ago

IE7 bug for $(expr, context) ;

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

Description (last modified by john) (diff)

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.

Change History

comment:1 follow-up: ↓ 2 Changed 6 years ago by john

  • Status changed from new to closed
  • Resolution set to worksforme

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.

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 6 years ago by geekinabox

  • Status changed from closed to reopened
  • Resolution worksforme deleted

Replying to 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)

comment:3 in reply to: ↑ 2 Changed 6 years ago by geekinabox

Replying to 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()) ;

comment:4 Changed 6 years ago by john

  • Status changed from reopened to closed
  • Version changed from 1.1.2 to 1.1.3
  • Resolution set to invalid
  • Description modified (diff)
  • Milestone changed from 1.1.3 to 1.1.4

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.