Side navigation
#6061 closed bug (invalid)
Opened February 09, 2010 01:54PM UTC
Closed February 10, 2010 05:06AM UTC
Last modified March 15, 2012 10:47AM UTC
jQuery won't find elements from ajax request data from within <head> tag
Reported by: | mtajur | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.2 | |
Component: | ajax | Version: | 1.4.1 |
Keywords: | ajax, head, find | Cc: | |
Blocked by: | Blocking: |
Description
If you do a ajax request using $.get(), and the result coming from the server is a full, valid xHTML 1.0 Transitional document, jQuery fails to find elements from the result that are placed inside the <head> tag, neither does jQuery find the <head> tag itself.
Example:
$(function() {
$.get('some.html', function(data) { alert( $(data).find('head').size() ); });
});
If some.html is a full xHTML page, with <head> tag and everything, this should result in alerting "1", but instead, jQuery finds neither <head> tag from the result nor any of the tags inside <head>.
In case I made any errors in the example, I'm sorry, but I've tested this with many working examples and asked a question about in on Stack Overflow (see http://stackoverflow.com/questions/2146594/how-to-replace-entire-css-of-a-page-after-an-ajax-request-with-jquery ) - no solutions so far. So it seems like a bug.
Attachments (0)
Change History (1)
Changed February 10, 2010 05:06AM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Yep, that's correct - parsing straight HTML we only guarantee the contents of the body element. If you wish to access the XML of the page directly then I recommend that you explicitly make the file .xhtml or request it as XML, for example: