Jump to content

Json Http


dustcomposer

Recommended Posts

I'm trying this w3schools tutorial about JsonHttp. All setted up but catch an error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I surfed to find solution but some suggest to use php. w3schools doesn't say anything about php in the tutorial above, so I get confused as I don't use php. All I want to do is open a .txt file (contains json) and access its some values. Any help?

 

Thanks!

 

* I run the function (js) from my pc to access .txt file which uploaded to a server.

 

 

Link to comment
Share on other sites

Two things: XMLHTTP requests don't work on the local filesystem for some browsers for security reasons. The second thing is that you cannot request a file that´s on a different domain name unless the server has been programmed to send a particular header in the response.

 

Here's a page explaining about cross-domain requests: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...