How to execute script injected by innerHTML after AJAX call with JavaScript?

Spread the love

To execute script injected by innerHTML after AJAX call with JavaScript, we put our code in a script block.

For instance, we write

<script type="text/javascript">
  function myFunction() {
    //...
  }
  myFunction();
</script>

to add a script block that has the myFunction function.

We call it after it’s defined.

Leave a Reply

Your email address will not be published. Required fields are marked *