加载使用jQuery外部JS文件 [英] Load external js file with jQuery

查看:105
本文介绍了加载使用jQuery外部JS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看着它无处不在,并找到了答案,但丢失了。任何人都知道如何从另一个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"
});

这篇关于加载使用jQuery外部JS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆