Nurutomo2

Get Text From URL [jQuery]

Sep 26th, 2018
1,277
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getDataFromURL(url) {
  2.     affixScriptToHead("https://code.jquery.com/jquery-3.1.1.min.js", function() {
  3.         $.get(url, function( data ) {
  4.             x = data
  5.         });
  6.     });
  7.  
  8.     function loadError(oError) {
  9.         throw new URIError("The script " + oError.target.src + " didn't load correctly.");
  10.     }
  11.  
  12.     function affixScriptToHead(uri, onloadFunction) {
  13.         var newScript = document.createElement("script");
  14.         newScript.onerror = loadError;
  15.         if (onloadFunction) { newScript.onload = onloadFunction; }
  16.         document.head.appendChild(newScript);
  17.         newScript.src = uri;
  18.     }
  19.  
  20.     return x;
  21. }
  22.  
  23. // Example Use
  24. getDataFromURL("https://pastebin.com/raw/PzgesDhD");
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment