0

even if I change the dataType to 'text', still the error event fires. I checked response data on jsonlint.com and it is valid json. Also status code is 200.

$.ajax({
    type:'GET',
    url:"https://api.flickr.com/services/feeds/photos_public.gne?id=29080075@N02&lang=en-us&format=json&nojsoncallback=1",
    data:"",
    success: function() {         

    alert("success");

    },

    error: function()
    {
     alert("error");

      },

     dataType:'json'
  });
  • If you check the console you'll see this error: `No 'Access-Control-Allow-Origin' header is present on the requested resource`. You're being blocked by the Same Origin Policy as Flickr does not send CORS headers with the response. This means you cannot do what you require using JS code alone. Closing as a duplicate. – Rory McCrossan Dec 23 '16 at 09:00
  • You need to change web config to allow – Mayur Patel Dec 23 '16 at 09:02
  • @RoryMcCrossan what is the best solution for `No 'Access-Control-Allow-Origin' header is present on the requested resource` ? if you dont have access to the page you are trying to access?my question is because of this [question of mine](http://stackoverflow.com/questions/40991377/access-steam-web-api-using-ajax-jquery) – guradio Dec 23 '16 at 09:03
  • @guradio It's never an ideal solution, but I'd normally build a server side proxy for the data. eg JS -> your server -> remote API, and then back again. It's slower, but if you need live data then there's not much of an alternative. – Rory McCrossan Dec 23 '16 at 09:09
  • @RoryMcCrossan when you say `JS -> your server -> remote API,` what do you mean by `your server` part how can i do it there? – guradio Dec 23 '16 at 09:21
  • 1
    That part would be written in your server side language, PHP or C# for example. – Rory McCrossan Dec 23 '16 at 09:26
  • @RoryMcCrossan i need a script in server to get data from the API? i see thank you rory – guradio Dec 23 '16 at 09:28
  • @RoryMcCrosson Thanks. This is probably a dumb question but if the same origin policy is to prevent me from accessing the data, why am I able to see the response data in chrome devtools. – Murali Kumar Dec 23 '16 at 09:45

0 Answers0