Weather App Project!

Hello, i have been trying for 2 days to finish the weather project but i am stuck, here is my code https://codepen.io/Stivi7/pen/NvdomP?editors=1010, i have tried different ways to update the location div but i get nothing! If someone can give some tips to help would be much appreciated!

Regards

The problem is that lat and long are not yet defined when the document is ready. So, the ajax request is made before you have the coordinates, which doesn’t work. In the getCurrentPosition function you can access lat and long, and that is also the only place where you can be sure that the coordinates are available. The logic of the ajax request has to be in the getCurrentPosition or (better) you call a function that makes the ajax request, from getCurrentPosition.