Is there a jQuery function to load a jQuery script stored in either Pastebin (http://pastebin.com/raw/AAirNTgx) or GitHub (https://raw.githubusercontent.com/DarkPotatoKing/darkpotatoking.github.io/master/IskoDuler.js) ?
Asked
Active
Viewed 84 times
0
-
1Can't you just add a ` – Robba Dec 06 '16 at 11:24
-
1why do you need to load a js file from code? – Yaser Dec 06 '16 at 11:24
-
`$.get("https://raw.githubusercontent.com/DarkPotatoKing/darkpotatoking.github.io/master/IskoDuler.js", function(data){$('head').append(' – A. Wolff Dec 06 '16 at 11:28
-
Our "app" is a Javascript bookmarklet that when run on certain site will do something, however when we have to update the script we have to tell the users to delete their current bookmark and get the new version of the bookmark from the site. So instead, I thought what if I just store the script somewhere then just load that from jQuery, so that when I update it I'll just edit the script online but the users will still use the same bookmarklet since it's just calling the script online – DarkPotatoKing Dec 06 '16 at 11:31
-
1@DarkPotatoKing You aware this is against their TOS?! – A. Wolff Dec 06 '16 at 11:33
-
@A.Wolff GitHub or Pastebin? – DarkPotatoKing Dec 06 '16 at 11:35
-
@DarkPotatoKing Both i guess... – A. Wolff Dec 06 '16 at 11:35
-
@A.Wolff Nope, I'm not aware. Do I have other options if I want to continue what I'm planning? – DarkPotatoKing Dec 06 '16 at 11:38
-
1@DarkPotatoKing I'm not that familiar with bookmarklet but i'm sure if instead of asking question regarding workaround, you ask question regarding your former issue, you'll get more relevant answer. See [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) So i think you should delete this question and ask a new one. But maybe i'm wrong and the way you are trying to handle it is a relevant way, i just don't know – A. Wolff Dec 06 '16 at 11:43
2 Answers
0
$.ajax({
url: url,
dataType: "script",
success: success //success callback handler..
});
or $.getScript()
and use url like https://rawgit.hubusercontent.com
NOT raw.githubusercontent.cpm
. why? Read here
I was able to load . Check jsbin here
-
$.getScript("https://raw.githubusercontent.com/DarkPotatoKing/darkpotatoking.github.io/master/IskoDuler.js") returns "undefined" $.ajax({ url: "https://raw.githubusercontent.com/DarkPotatoKing/darkpotatoking.github.io/master/IskoDuler.js", dataType: "script", success: success }); returns "ReferenceError: success is not defined " – DarkPotatoKing Dec 06 '16 at 11:29
-
success is a function call to do on receiving your script.. you can remove that parameter if you are not interested in it. – Sunil B N Dec 06 '16 at 11:38
-
-
can you paste the code what you are trying in question? you can check in network tab of browser whether the file has been loaded or not.. – Sunil B N Dec 06 '16 at 11:41
-
$.ajax({ url: "https://raw.githubusercontent.com/DarkPotatoKing/darkpotatoking.github.io/master/IskoDuler.js", dataType: "script" }); – DarkPotatoKing Dec 06 '16 at 11:42