Andy T
Andy T

Reputation: 9891

Injecting JavaScript after ajax call

I am looking for a way to have JavaScript dynamically loaded after an ajax call to load a dialog/pop up.

I would like the dialog to load it's own JavaScript files and any in-line JavaScript.

I have seen examples that use a method to do an ajax call to load html into the DOM then have "complete" callbacks that the loading method will call after the html is loaded.

However, using this approach prevents any JavaScript on the dialog from executing and requires that the initiating JS know details about the dialog in order for it to attach events, etc.

Is the only way to accomplish this to have the dialog load the source of the document into an iframe so that it can run the JavaScript?

Upvotes: 2

Views: 820

Answers (1)

Related Questions