Forcing Script To Run In Ajax Loaded Page
So I am using an AJAX loader on my WP installation and one of the pages I am loading has a script in it.
Solution 1:
Before anything else, you should wrap your function in a .ready()
to ensure all DOM elements are loaded before you do something to those elements
Also, scripts within HTML that are returned via ajax functions in jQuery are executed only when the HTML is appended in the DOM. Since you did not append the html containing the code, the script in that returned content won't run.
Take a look at the .ajax()
function's parameters, under dataType
dataType:
...
"html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.
...
Post a Comment for "Forcing Script To Run In Ajax Loaded Page"