Skip to main content

Bug Tracker

Side navigation

#3409 closed bug (invalid)

Opened September 25, 2008 01:00PM UTC

Closed May 14, 2009 02:01AM UTC

Last modified September 07, 2011 08:12PM UTC

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.

Attachments (0)
Change History (7)

Changed September 25, 2008 04:36PM UTC by flesler comment:1

cc: → Just, flesler
owner: → john

Changed September 30, 2008 08:32AM UTC by Just comment:2

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

Changed October 10, 2008 05:54AM UTC by Just comment:3

Under safari that mess up !

I can't get head element at all :/.

Changed May 14, 2009 02:01AM UTC by dmethvin comment:4

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.

Changed December 15, 2010 08:18PM UTC by snover comment:5

#7784 is a duplicate of this ticket.

Changed December 16, 2010 06:22PM UTC by cowboy comment:6

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

Changed September 07, 2011 08:12PM UTC by ajpiano comment:7

#10222 is a duplicate of this ticket.