0

On success of ajax request, i load a script using,

$.getScript(base_url + 'js/js_to_be_loaded.js');

Is there any way i could check if that particular script is already loaded ?

Thanks.

4

1 に答える 1

2

successコールバック関数を実装するだけで済みます。

jQuery.getScript( url [, success(script, textStatus, jqXHR)] )

お気に入り:

$.getScript(base_url + 'js/js_to_be_loaded.js', onSuccess);

function onSuccess(...)
{
    // in this function you are guaranteed that it is loaded
    // so you can execute code based on the loaded js file or
    // set flags to let your code "know" that it is loaded
}
于 2012-08-21T10:05:48.357 に答える