javascript - CORS to read a text file from a pastebin -


i hoping use cors load code snippets pastebin, process them in browser.

some code in progress here: http://www.boisvert.me.uk/opendata/sparql_aq+.html

the code highlighted , there options run etc.

i'd provide simple service, user saves text anywhere public, queries:

http://www.boisvert.me.uk/opendata/sparql_aq+.html?sparqlurl=whatever-url

for example, url is:

http://pastebin.com/raw.php?i=gruu9zwe

http://www.boisvert.me.uk/opendata/sparql_aq+.html?sparqlurl=http%3a%2f%2fpastebin.com%2fraw.php%3fi%3dgruu9zwe

but when using cors, repository returns empty file. cors blocked systems (e.g. pastebin.com?) or doing wrong?

i attach images firefox debugger, showing, unless i'm missing point, blank response returned cors, , in case helps, headers.

firefox network tool - request ok, result appears blank the same problem, different sceenshot

finally, cors code:

function corsrequest(url) {    var xhr = new xmlhttprequest();     if ("withcredentials" in xhr) {       // check if xmlhttprequest object has "withcredentials" property.       // "withcredentials" exists on xmlhttprequest2 objects.       xhr.open("get", url, true);    } else if (typeof xdomainrequest != "undefined") {       // otherwise, check if xdomainrequest.       // xdomainrequest exists in ie, , ie's way of making cors requests.       xhr = new xdomainrequest();       xhr.open("get", url);    } else {       // otherwise, cors not supported browser.       throw new error('cors not supported');    }     if (xhr) {       xhr.onload = function() {          // process response.          document.getelementbyid("sparql").value = xhr.responsetext;       };       xhr.onerror = function() {          alert('not loading.');       };    }    xhr.send(); } 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -