0

I have Problems after 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..

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.