What am I doing wrong here?
var country = function () {
var tmp = null;
$.ajax({
'async': false,
'dataType': 'jsonp',
'url': "http://ipinfo.io",
'success': function (data) {
tmp = data.country;
}
});
return tmp;
}();
console.log(country);
prints null
async is set to false, so it should work? What is wrong here?
BTW if I put console.log(data.country)
inside success call it prints the country correcty