Is the callback on jQuery's getScript() unreliable or am I doing something wrong?

后端 未结 11 1282
Happy的楠姐
Happy的楠姐 2020-12-03 03:17

I\'m using the following bit of script to load another one:

$.getScript(\"CAGScript.js\", function () {
    try {
        CAGinit();
    } catch(err) {
              


        
11条回答
  •  Happy的楠姐
    2020-12-03 03:48

    If the file is held on the same domain then jQuery will use XHR to retrieve its contents and then will globally "eval" it. This should work fine but if you're having problems then I'd suggest using the alternative method of injecting a script tag. Unfortunately, jQuery doesn't expose this functionality so you'll have to do it yourself:

    var script = jQuery('
    
                                     
                  
提交回复
热议问题