How do I load a static, plaintext json file into Javascript with a GET request? -


this question has answer here:

this 1 testing with, specifically:

static json data

i have run many cross-site request errors, though don't see how should different requesting image statically hosted on same site, can load test html file.

i have tried following:

$.getjson('http://anyorigin.com/get?url=maxcandocia.com/static/blog/test_output3.json&callback=?',   function(data){     $('#output').html(data.contents); });  var network_data  $.getjson("http://maxcandocia.com/static/blog/test_output3.json",  function(data){     network_data = data.contents; }) 

in general, can't access resource on origin (in essence domain-port combination) through javascript unless origin explicitly allows through use of specific headers, access-control-allow-origin.

it seems anyorigin.com, service you're using, reason fails redirect correctly; not appear fault, wrong service. recommend try other, equivalent service, such https://crossorigin.me/ (just add https://crossorigin.me/ in front of url):

var network_data; $.getjson("https://crossorigin.me/https://maxcandocia.com/static/blog/test_output3.json",  function(data){     network_data = data.contents; }) 

if control server yourself, better set server send access-control-allow-origin header json file.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -