<script>
$(document).ready(function(){
$.get("https://ipinfo.io", function(response){
var city = response.city;
$("#details").html(JSON.stringify(response, null, 4));
}, "jsonp");
});
alert(city);
</script>
Is there any possible way to convert $.get asynchronous variable to a classic one that can be printed inside div or span?
I know that usually returns promise, is there no possible way in JS to convert promise to some variable and make it global so all other functions can access it?