Opened 16 years ago
Closed 16 years ago
#1111 closed bug (invalid)
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 (last modified by )
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 (4)
comment:1 follow-up: 2 Changed 16 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 follow-up: 3 Changed 16 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
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 Changed 16 years ago by
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 16 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.1.3 → 1.1.4 |
Resolution: | → invalid |
Status: | reopened → closed |
Version: | 1.1.2 → 1.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.
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:
that should give you "test" as a result.