AJAX PHP回应js代码,它不起作用[重复]

This question already has an answer here:

I'm writing an AJAX page with php, which will echo a block of JS code when it finishes. Although the JS code is embedded into HTML page, it doesn't work. How can I make it work?

</div>

Browsers generally don't execute js in ajax sections, for security reasons.

You'll want to provide the final javascript to be executed in a callback to the ajax load functionality instead.

Even better, just include the javascript from the target page in an external initialization function (e.g. function finalizeProfilePage()) in some siteName.js file and then load that upon completion of the ajax load and where-ever else you use that page content.

I'm right now working on something similar. To execute the code loaded through ajax i just need to call the function like this:

jQuery(function() {
        loadScript();
    });

(yes i'm using jquery )