What do you mean print them to the “screen” is that the console or you want to render them in your html?
1 Like
You need to put your AJAX call inside your callback function to the geolocation.
Otherwise when the AJAX is called, lat and lon are not defined yet.
There are some pretty good explanations of asynchronous behavior in this thread.
2 Likes
it worked. thanks so much
This sort of asynchrony is a vey important concept in JS. This will come up and again. There are a couple of ways to solve it, but putting things in the callback function is the most basic and the best one to learn first.