Skip to content Skip to sidebar Skip to footer

Cascading Object Declaration Gives Undefined Typeof From Second Object On

I load js files dynamically in my project putting their content in a script tag in the head. Each file has only an object inside. I noticed that after loading, all objects are in t

Solution 1:

There is a big difference between loading and executing. The best place to check all objects are ready is on DOMContentLoaded event.


Solution 2:

I would use Javascript to load all core modules but I will change to JQuery. The problem is related to the xmlhttprequest method plus the innerHtml method. First time, the browser interpret the code inside. From second on it just add the content. To continue on this way it would be better to create an element (script) each time and append it to the head

var elm = document.createElement('script');
elm.innerHtml = //content retrieved;
document.head.appendChild(elm);

Post a Comment for "Cascading Object Declaration Gives Undefined Typeof From Second Object On"