I am working on a geolocation script, but I can’t get the content of my function.
Is there someone who can help me?
The code look like this:
<script type="text/javascript">
var myvalue1;
navigator.geolocation.getCurrentPosition(function()
{
myvalue1 = 'test';
window.myvalue2 = 'demo';
});
console.log(myvalue1);
console.log(window.myvalue2);
</script>
Both returns undefined and I simple don’t know how to pull the data.
Hope someone can help me.
Thanks in advance.
It is asynchronous call. Try this