I have Problems after开发者_如何学C loading a whole new page via Ajax to get all inline JS and CSS executed. The result of this call is a whole new page including , i want to replace with current content. Does JQuery provide functionality to execute all scripts after success of an Ajax Call? My first idea was to select all script tags from result and append it to the body. Second idea was to selecet all script tags and execute their contents with eval(). Thx for helping..
When you call .html()
in jQuery to insert the returned HTML into the page, all inline scripts will be executed. For example: http://jsfiddle.net/Paulpro/LX58E/
Or:
var html = '<script type="text/javascript"> alert(\'Hi\'); <\/script>';
// Execute the script twice
$('body').html(html+html);
精彩评论