API AJAX Error

Tagged:

Currently contains 4 posts

Avatar

July 30, 2015 02:37

Hagan McPhail

I keep getting “No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.” when I try the call below.

$.ajax({
url: ‘http://api.weatherunlocked.com/api/forecast/51.50,-0.12?app_id=app_id&app_key=app_key’,
type: ‘GET’,
dataType: “json”,
success: function () {
alert(‘suc’);
},
error: function (error) {
alert(‘fail’);
}
});

Avatar

August 03, 2015 13:37

Marco

Hi Hagan,

We’ve just added Cross-Origin Resource Sharing (CORS) support to our local weather api.

You should now be able to get a valid response.

Please let us know if you need anything else.

Regards.

Avatar

August 04, 2015 14:57

Hagan McPhail

Awesome! Thanks! Works like a champ now!

Hagan

Avatar

August 22, 2018 20:43

Tim Foster

I’m getting the same thing. I can call the api directly in a browser and get a response, but if I try to call it from a webpage, I get the error:
SEC7120: [CORS] The origin ‘http://www.domain.com’ did not find ‘http://www.domain.com’ in the Access-Control-Allow-Origin response header for cross-origin resource at ’https://api.weatherunlocked.com/api/current/51.5,-0.1?app_id={id}&app_key={key}.

HTTP403: FORBIDDEN – The server understood the request, but is refusing to fulfil it.

(XHR)GET – https://api.weatherunlocked.com/api/current/51.5,-0.1?app_id={id}&app_key={key}.

Reply to thread
  1. If you're human, leave this field empty.