繁体   English   中英

检查外部js文件是否已加载

[英]Check if the external js file is already loaded

在ajax请求成功后,我使用加载脚本,

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

有什么方法可以检查是否已加载该特定脚本?

谢谢。

您只需要实现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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM