Weather app help please

I’m not sure what I’m doing wrong and I’ve messed around with my code for the past week, changed it, stared at it, googled, etc. I don’t understand what I’m doing wrong. The only thing that comes up on the console is that I need to have Tether, but when I try to add it to my CodePen, it doesn’t allow me, and there are no other errors, however, when I click the button nothing happens.

How about putting the geolocation code inside the click event handler?

I had no success too. I’ve been trying for 2 days now.
Please share if you come across a solution.

I can’t even get the APIs to run properly or use geolocation.


my dosent work now presumably because openweather uses http and codpen uses https …
but in your case its structured wrong … i rearranged it to look like this … i also copied the code to notepad and saved a index file to a folder on my desktop and the javascript to a file … i then opened the folder in the browser and clicked the button and it worked … so you could try it that way just to see it working … else you going to have to look up cross origin problems
$(document).ready(function(){ if (navigator.geolocation) { function getCurrentLocation(position){ ..... // i wont bother fill it in ....your code } $("#weatherButton").click(function(event) { // call your function here; navigator.geolocation.getCurrentPosition(getCurrentLocation); console.log(longitude) // rest of your code }; }: })

here is an example