Bug Tracker

Opened 8 years ago

Closed 7 years ago

#4706 closed bug (fixed)

Ajax load(...) works wrong with full HTML documents

Reported by: hvesalai Owned by:
Priority: major Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:


The ajax "load( url, data, callback )" function documentation states that the default selector is "body > *". This is not what actually gets loaded.

The load(...) function uses the "jQuery( html, ownerDocument )" to parse the HTML that is loaded. The documentation of jQuery(...) states: "The HTML string cannot contain elements that are invalid within a div, such as html, head, body, or title elements." This is correct, i.e. documentation actually describes the implementation.

Since the jQuery(...) will not return the body element, then the selector used by load(...) will never be used and hence the load(...) function will also return elements that were in the loaded HTML documents head (such as meta, script, etc).

The effect of this bug is that you cannot load the body elements of an HTML document. The workaround is to include a div with an id around all the content that you want to load and select the content of that, i.e. load("http://my/url div#myid > *").

At least the documentation of load(...) should be corrected to reflect what will actually happen.

Change History (1)

comment:1 Changed 7 years ago by dmethvin

Resolution: fixed
Status: newclosed

Hopefully I've clarified the documentation.

Note: See TracTickets for help on using tickets.