加载使用jQuery外部JS文件加载、文件、jQuery、JS

2023-09-10 13:56:32 作者:爱情有保质期

看着它无处不在,并找到了答案,但丢失了。任何人都知道如何从另一个js文件加载外部js文件?

Looked for it everywhere, and found the answer but lost. anyone knows how to load an external .js file from another js file?

main_lobj1.onreadystatechange = function(){     
  if (main_lobj1.readyState == 4) {if (main_lobj1.status == 200) { 
    document.getElementById("middleDiv_m").innerHTML=main_lobj1.responseText;  
  jQuery.getScript('jquery/tabs.js')        
  }
}

innerHTML的工作原理和性反应的文本粘贴。问题是,JS不工作在该文件中。 jQuery.getScript应该是加载外部的js文件,但它不

innerHTML works and responce text is pasted. The problem is that JS is not working in that document. jQuery.getScript should be loading that external js file, but it doesnt

推荐答案

这是你能做到这一点加载外部JS文件jQuery的方式

$.ajax({
  type: "GET",
  url: "test.js",
  dataType: "script"
});