JSFiddle - React, Tailwind, and code Playground
by MarkSchultheiss
JavaScript
var ip = {};
var country = {};
var getstuff = {};
function callback(response) {
ip = response.ip;
country = response.country_code;
return [ip, country];
}
function getVisitorData() {
getstuff = $.ajax({
type: "GET",
url: "http://freegeoip.net/json/",
dataType: "json",
async: true
}).done(callback)
.fail(function (response) {
alert("IP thing didn't work.");
});
}
jQuery(document).ready(function () {
getVisitorData();
getstuff.done(function () {
alert(ip + country);
});
});