如何使用jQuery从url加载另一个jQuery脚本?

时间:2016-12-06 11:22:54

标签: javascript jquery

是否有一个jQuery函数来加载存储在Pastebin(http://pastebin.com/raw/AAirNTgx)或GitHub(https://raw.githubusercontent.com/DarkPotatoKing/darkpotatoking.github.io/master/IskoDuler.js)中的jQuery脚本?

2 个答案:

答案 0 :(得分:0)

$.ajax({
  url: url,
  dataType: "script",
  success: success //success callback handler..
});

$.getScript()

并使用https://rawgit.hubusercontent.com NOT raw.githubusercontent.cpm之类的网址。为什么? Read here

我能够加载。 Check jsbin here

答案 1 :(得分:0)

您可以通过替换源文件或路径文件

来尝试此操作
<script>
   $( "#new-projects" ).load( "/resources/load.html #projects li" );
</script>