Javascript 如何防止$.getScript执行document.ready内容?
我想调用另一个JavaScript文件中的函数Javascript 如何防止$.getScript执行document.ready内容?,javascript,jquery,Javascript,Jquery,我想调用另一个JavaScript文件中的函数 function foo(){ //before $.getScript $.getScript('otherScript.js', function() { otherFoo(); }); //after $.getScript } 但这将在调用otherFoo()函数之前执行otherScript.js的整个$(document).ready()部分。如何防止调用$(document).rea
function foo(){
//before $.getScript
$.getScript('otherScript.js', function() {
otherFoo();
});
//after $.getScript
}
但这将在调用otherFoo()函数之前执行otherScript.js的整个$(document).ready()部分。如何防止调用$(document).ready()并仅调用otherFoo()函数?您不能这样做
它将运行整个文件。如果您不想运行任何东西,请将所有内容放在函数的otherScript.js中
如果不编写单独的解析器,您想要做的事情是不可能的。我认为您做不到。