Jump to content

No 'Access-Control-Allow-Origin' header is present on the requested resource


Girish Dubey

Recommended Posts

I am trying to get data from other server and i get right response as well as below error


XMLHttpRequest cannot load http://dex2y.xyrn.com/data/profiledata.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:56711' is therefore not allowed access.




Request:


$.ajax({ url: "http://dex2y.xyrn.com/data/profiledata.json", async: false, dataType: "json", success: function (json) { exampleValues = json; } });



Response:


{

"header": "Bob's Profile",

"name": "Bob Robertson",

"address": "1010 Some Street, New York, NY, 10001",

"phone": "(212) 555-1212",

"interests": "Bob likes apples, big ones and floating ones."

}



and i am not able understand about this error.

post-178898-0-51243300-1456982641_thumb.png

Link to comment
Share on other sites

You can only send AJAX requests to the same domain the page is hosted on. In order to send AJAX requests to other domains the server needs to be set up to send an "Access-Control-Allow-Origin" header which includes the domain name you're sending the request from.

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...