you can write Ajax code with JavaScript code, like this
<script>
$(document).ready(function() {
function ipLookUp() {
$.ajax('https://ipapi.co/json/')
.then(
function success(response) {
var country = response.country_name.split(' ').join('_').toLowerCase();
alert(country)
//if you need class in body
$('body').addClass(country);
},
function fail(data, status) {
console.log('Request failed. Returned status of',
status);
}
);
}
ipLookUp();
});
</script>