Weather app only just stopped working, only works when I copy and paste code onto a new pen

Here’s my code pen. https://codepen.io/david_vu408/full/OWOmNZ/. I have figured out that the code only works when I copy and paste it to a new pen. Does anybody know the problem as to why this is?

I found out that once I removed the jquery document ready function everything works! Anyone have an explanation?

That’s… weird. What do you mean by “stopped working”? I’m not seeing any weather or location data, but no errors either, and no $(document).ready function.

The location and weather is not appearing! It’s supposed to show City, State, Zip code and current weather

“Mixed Content: The page at ‘https://codepen.io/david_vu408/full/OWOmNZ/’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://api.openweathermap.org/data/2.5/weather?zip=08002,us&appid=652c6e2245db3ca4eae76e7d899139ff&units=imperial’. This request has been blocked; the content must be served over HTTPS.”

looks like an http - https problem.

1 Like

Can you further elaborate on this Sergi-O? I figured that if I change the getJSON request to an http link and not https it works. But still do not understand why.

I’m really not sure myself, but that console error gives plenty to get lost in Google and find and answer : ) it’s a lead.

OpenWeatherMap doesn’t allow secure connections to their API. This issue comes up every couple of days, as does the solution. There’s some more info here:

Essentially, use a different API or a CORS proxy.

1 Like

I used the OWN and GeoIP … and as for [quote=“PortableStick, post:8, topic:81250”]
Essentially, use a different API or a CORS proxy.
[/quote]

none of that is/was covered in the training/tutorials up to the point of this challenge. There’s no way a camper would know any of that unless they’ve had prior exposure to alternative API’s and definitely proxies.

Yes, it’s a known problem, and one that should be addressed in the upcoming curriculum update. Learning to code is hard. Teaching someone else to code is even harder. Teaching everyone to code is a task so large that it can only be taken on incrementally. Things will only be improving.

Also keep in mind that this is one of the reasons we have the forums.

It appears that now the weather underground API has changed so that this is a problem with it as well. Just so people know. Or maybe it’s just me…