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.
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.