Ajax load(...) works wrong with full HTML documents
|Reported by:||hvesalai||Owned by:|
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.