0

I am trying to load a .js file into a div which document.writes() some HTML elements into the div

Example :

<div style="overflow: hidden">
    <script type="text/javascript" src="https://xyz/abc.js"></script>
</div>

Now this .js file on AJAX asynchronous postback does not executes.

How can I re-register the file into the div? Or how can I run this .js file on asynchronous postBack

Thank You.

ozil
  • 6,930
  • 9
  • 33
  • 56
Priscilla Jobin
  • 609
  • 7
  • 19

2 Answers2

0

Apply a prefixed id (just to avoid name clash) to the div and refer that id in the js file the you want to load. And add async attribute to the script tag.

<div style="overflow: hidden" id="prefix-targetdiv"></div>
<script type="text/javascript" src="https://xyz/abc.js" async></script>     
obuliraj
  • 106
  • 7
0

You could modify the src attribute to reload the external script. One example could be to use a made-up query string appended to the actual JavaScript URL:

<script type="text/javascript" src="https://xyz/abc.js?some-random-string-to-reload-the-external-script"></script>

Related question: Refresh external loaded javascript files

Community
  • 1
  • 1
Ted Nyberg
  • 7,001
  • 7
  • 41
  • 72