Girish Dubey Posted March 3, 2016 Share Posted March 3, 2016 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. Link to comment Share on other sites More sharing options...
Ingolme Posted March 3, 2016 Share Posted March 3, 2016 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 More sharing options...
justsomeguy Posted March 3, 2016 Share Posted March 3, 2016 That means that the other server needs to be configured specifically to allow your server to contact it through Javascript. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now