Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
New feature: You can now inject portions of a document via .load(), a…
…s opposed to the full thing. Examples: - $("#test").load("test.html #something"); - $("#test").load("test.html p.user"); Caveats: - No scripts are injected when a selector is used. - The selector is rooted inside the head and body - it's equivalent to doing: $("body,head").find(selector)
- Loading branch information
34f1042
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very curious about the prohibition on inline scripts in requested content before insertion into the document. In some testing of this (upon running into it the hard way) I've been unable to generate the suggested
Permission Denied
errors in IE. Are there any old bugs that this referenced or other form of documentation on the issue being worked around? Some discussion on the topic I've found suggests that if thedefer
attribute is specified on the script then the permission denied error won't be generated. Just as soon as I can reliably generate such an error I plan to investigate the suggested effects of thedefer
attr.34f1042
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count me curious too
34f1042
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a forum post about this at http://forum.jquery.com/topic/fn-load-stripping-inline-scripts
34f1042
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not encounter any such errors but script stripping was helpful on few occasions. I had a case where I wanted to avoid reloading the same page but to insert just the parts that changed. When I obtain responseText and create DOM fragment (disconnected) in order to query it for elements I need, IE runs all scripts in the fragment, effectively re-initializing everything I have on the page. The way $.load works was just what I needed.
34f1042
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve encountered that rerunning of scripts (I believe it's more than just IE) as I’ve been working through things and it’s definitely got its good and bad aspects to it. But if the
defer
attribute steps around that issue, it seems like the script regex should avoid those scripts so that we have a way to allow scripts to opt-out of being inserted into the page.