While working on the local weather app project I ran into trouble displaying the weather data from openweathermap.org onto the console. I’m able to get my lat/long and concat it onto the url but I get the following error on the web console:
I’ve looked up several videos and articles on JSONP but none of the suggestions work (I get the same error). I understand that this is because my browser is not allowing me to access data from a different domain as a means of additional security(or something to that effect), and that JSONP is a technique to bypass those protections.
Unfortunately I’m not having any luck solving the issue, if anyone can help me solve this issue or point me in the correct direction it would be greatly appreciated. Here’s the link to the project. Thanks in advance!
I gave it a shot, but maybe take a look at the
cross-origin property of
$.AJAX() and see if allowing that in the AJAX call makes a difference.
Also there’s a great program for making and returning API data which has been a big help to me on projects like this one. It’s called Postman I would recommend trying it out and just try to get the return data working. That way you can separate the API calls from the rest of the project
Also heres the link to my weather app in case you want to see a working request. I also added
&units=imperial before the API key
Thanks for the suggestion! It turns out after some tinkering adding https:// to the beginning of the url solved the issue. I don’t know precisely why it solved the problem, but my guess at the moment is the additional security? Thank you for responding to my post.
Great I’m glad it worked out. Yes it has to do with Chrome (and maybe other browsers) NOT allowing websites to use the location API without a secure connection. I think