Bug Tracker

Opened 15 years ago

Closed 14 years ago

Last modified 12 years ago

#3409 closed bug (invalid)

Can't get HEAD element from an AJAX return

Reported by: Just Owned by: john
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: Just, flesler
Blocked by: Blocking:

Description

Using this <js>alert($('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>Test</title></head><body>InnerHTML\'s body</body></html>').html());</js>

It display me "Test". So the TITLE element's content. Can't get any one of the HTML, HEAD or BODY element. Can access the element in the BODY element but not those which is in the HEAD element.

Change History (7)

comment:1 Changed 15 years ago by flesler

Cc: Just flesler added
Owner: set to john

comment:2 Changed 15 years ago by Just

All the element is finally put "the one after the other". Just removing the HTML, HEAD, and BODY elements. so that html

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>Test</title></head><body>InnerHTML\'s body</body></html>

looks like this

<title>Test</title>InnerHTML\'s body

comment:3 Changed 15 years ago by Just

Under safari that mess up ! I can't get head element at all :/.

comment:4 Changed 14 years ago by dmethvin

Resolution: invalid
Status: newclosed

You can't swallow a whole html document with $("html"); whatever you pass in as a string has to be valid within a div:

http://docs.jquery.com/Core/jQuery#htmlownerDocument

As an alternative, you could use an XML parser ouside of jQuery if the markup is valid XML and pass that to $() instead.

comment:5 Changed 12 years ago by snover

#7784 is a duplicate of this ticket.

comment:6 Changed 12 years ago by cowboy

FWIW, I've written a plugin called jQuery htmlDoc that attempts to address this issue. It probably needs more testing, but in my basic tests it works well:

http://benalman.com/projects/jquery-misc-plugins/#htmldoc

comment:7 Changed 12 years ago by ajpiano

#10222 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.