0

I have following js includes:

<script src="~/js/api/config.js"></script>
<script src="~/js/authentication.js"></script>
<script src="~/lib/es6-promise-polyfill/promise.min.js"></script>
<script>Vue.use(VeeValidate)</script>
<script src="~/js/home.js"></script>

authentication.js has an ajax call. home.js must not be called before authentication and its ajax calls has completed. Is this possible?

Aftab H.
  • 1,493
  • 4
  • 12
  • 25
NatJJ
  • 17
  • 5
  • 1
    load home.js in callback/promise complete of that ajax call? – mehulmpt Feb 26 '18 at 10:48
  • check this answer out for dynamically loading js script: https://stackoverflow.com/questions/14521108/dynamically-load-js-inside-js – andnik Feb 26 '18 at 10:53

1 Answers1

0

You can call the following function from xmlhttp.onreadystatechange event

function loadJS() {
    var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = '/js/home.js';
    document.getElementsByTagName('head')[0].appendChild(s);
}
Rohit416
  • 3,114
  • 3
  • 21
  • 38
tano
  • 1,713
  • 1
  • 9
  • 12