For example, I have three tabs (tabs), when I switch to a tab, an AJAX request is made and the HTML + JS content is obtained, which is inserted, for example, in the <div> tab. HTML is rendered normally, and JS in this case is not executed. The question is how to execute the JS code that came along with the HTML markup as the result of an AJAX request.

  • And why did you decide that js is not executed? Not running and not working are different things. - Lucky
  • Well, for example dev.sencha.com/deploy/ext-4.0.0/examples/tabs/tabs.html if you go to the Ajax Tab 1 tab, then the ajax1.htm file is loaded and then its contents are displayed in the tab. The question is, if you include a script in ajax1.htm, for example, <script> alert ("test"); </ script> then when it is loaded it will not be executed. - abg


1 answer 1

Getting ajax html is not the best idea, but that's up to you.

Scripts wrapped in <script> execute by themselves. But those that the links need to deflate and wrap in <script> .

For everything else, if an event is hung up on onload in the scripts, they will not be executed.

  • Through eval it is bad because then, when any error occurs, it is almost impossible to debug it. - abg
  • @abg stump is clear that it is difficult to debug, but it is connected. So debugging of such scripts needs to be dealt with separately. This is the same as shrinking a script, and then looking for errors in a snare. - lampa