From your comments, you want the loaded scripts to run in some kind of "partial" document context, limited by the contents of your externalpage element (that is, only the loaded <h1> element should be modified, not the external <div> ).
This can be achieved by temporarily overriding $.find() (not $ .fn.find () , this is not the same thing) and substituting the externalpage element in the context argument if it is not specified or equal to the document itself:
$(document).ready(function () { $.ajax({ url: "/ajax/Index", success: function(data) { var $root = $(".externalpage"); var realFind = $.find; $.find = function(query, context, extra, seed) { return realFind.apply(this, [ query, context && context !== document ? context : $root[0], extra, seed ]); }; $root.html(data); $.find = realFind; } }); })
jsFiddle has an echo function that I could use to test this solution. You can see the results here .
source share