ajax请求成功后,我使用
加载脚本$.getScript(base_url + 'js/js_to_be_loaded.js');
有什么方法可以检查是否已加载该特定脚本?
感谢。
答案 0 :(得分: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
}