$.getScript loading file but not executing it

Viewed 1159

I'm trying to load a javascript file using jQuery's $getScript, I'm loading the script on button click. The script is supposed to append a node's content into another node, the problem is that I see the script is loaded but it's not executing.

<script type="text/javascript">
$('#but').on('click', function(){

  $.getScript('/static/39f3e10/js/wrapperloadxb.js')
    .done(function(textStatus) {
      /*optional stuff to do after getScript */
      console.log('script is loaded');
    })
    .fail(function(jqxhr, settings, exception){
      console.log("error");
    })

});


</script>

the script to load

var wrapper  = function(){
  var ul = document.getElementById('xbUL');
  var container = document.getElementById('xxx');
  container.appendChild(ul)
  };

PS: I'm adding $.getScript inside an underscore template script

1 Answers
Related