Ticket #6307 (closed bug: wontfix)
jQuery .load() does not execute scripts when called with a selector in the URL
|Reported by:||Pointy||Owned by:||Pointy|
The ".load()" API always removes script blocks from the markup loaded into the document. However, when called with a plain URL lacking a suffixed selector expression, the loaded content is handed to the ".html()" API before scripts are removed, and that code takes care to save and execute the stripped-out script blocks before throwing them away. When called with a selector expression appended to the URL, the scripts are stripped out before the DOM is updated and so are never executed.
Note that in both cases I'm talking about script blocks within the content actually loaded into the target DOM. In the first case, that's obvious, because the content returned from the xhr is always loaded in its entirety. In the second case, that of there being a selector at the end of the URL, I'm talking about script blocks within the response portion chosen by the selector.
This is not a subtle issue and it's trivial to demonstrate by example, and the cause is quite obvious in the "load()" code. It may be that there's a good reason for the difference in behavior, but there's no mention of how scripts are handled by "load()" in the documentation.
- Owner set to Pointy
- Priority set to low
- Status changed from new to pending
- Keywords script execution, load added
- Status changed from new to open
- Milestone changed from 1.4.3 to 1.5
- Keywords script,execution,load,ajaxrewrite added; script execution, load removed
- Keywords script,execution,load,ajaxrewrite,needsdocs added; script,execution,load,ajaxrewrite removed
- Status changed from open to closed
- Version changed from 1.4.2 to 1.6b1
- Resolution set to wontfix