Waiting for dynamically loaded script

前端 未结 6 1758
忘了有多久
忘了有多久 2020-11-30 08:28

In my page body, I need to insert this code as the result of an AJAX call:

    

Loading jQuery

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 09:12

    There is also new feature in jQuery 1.6. It is called jQuery.holdReady(). It is actually self explanatory; when you call jQuery.holdReady(true), ready event is not fired until you call jQuery.holdReady(false). Setting this to false will not automatically fire a ready event, it just removes the hold.

    Here is a non-blocking example of loading a script taken from the documentation:

    $.holdReady(true);
    $.getScript("myplugin.js", function() {
         $.holdReady(false);
    });
    

    See http://api.jquery.com/jQuery.holdReady/ for more information

提交回复
热议问题