Hello everyone, I'm new here so please be patient with me.
I have a question about two similar web APIs that I'm working with. Both can be accessed through the browser, but only one seems to work properly with jQuery. What could be causing this discrepancy?
The first API works perfectly fine when accessing it through the browser and using getJSON:
$.getJSON("http://api.openweathermap.org/data/2.5/weather?q=london&appid=33d0ba5efa0edb1a2282c3165b00d15e&units=metric")
.done(function(json) {
console.log("JSON Data: " + json.name);
})
.fail(function(jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
console.log("Request Failed: " + err);
});
The second API is very similar to the first, but for some reason, it only works when directly accessed from the address bar. If you try to get JSON data from it, either nothing happens or an error is thrown:
$.getJSON("http://info.studyinpoland.pl/admin/public/api/events")
.done(function(json) {
console.log("JSON Data: " + json[0].id);
})
.fail(function(jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
console.log("Request Failed: " + err);
});
Any idea why this might be happening? I really need to access the data from . Are there any other ways to retrieve this data using JavaScript?