Load the libraries, and then perform the function.



  • Scripts need to be fully downloaded, and only then perform the function. The current version doesn't work. What is the need to correct?

    if (Type == '1') {
        var getAnimation_1 = $.getScript('{0}/animation/1.js'.format(s.scripts));
        $.when(getAnimation_1).then(animation);
    };
    

    if (Type == '2') {
    var getAnimation_1 = $.getScript('{0}/animation/1.js'.format(s.scripts));
    $.when(getAnimation_1).then(animation);
    };



  • I rarely use $when ().then() and usually follow more conservative working methods, so I don't know about underwater rocks in this way. But the code proposed below, 100% will work as you expect, the function will only be performed after the crypt is downloaded:

    $.getScript('{0}/animation/1.js'.format(s.scripts), animation);
    

    or

    $.getScript('{0}/animation/1.js'.format(s.scripts), function(){
        //do something
    });
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2