My AJAX returns a block of code in JS. I have tried converting this to a function that is then called AFTER the AJAX request returns, but for some reason in my FireBug console I am being told the function doesn't exist. The AJAX returns a block of JS and sets it into a div called "content". However, these functions do not appear to register and aren't called. Even when they aren't functions and are standard statements that would otherwise execute they still do nothing!
Absolutely everything is in place and works perfectly except this final part where the returned JS code doesn't execute.
Clearly, the JS code block isn't inside the <head>
element, however, I am sure I've managed to execute JS code outside of that element before.
Is there anything I am doing majorly wrong, and is there a work around? The JavaScript code block edits the localStorage
and so I cannot use another language instead, the code block is also generated using PHP and is dynamic as it changes variables depending on user input.