Getting the country code from IP address

Will do this server side to determine if the visitor can or cannot view the site

HTML

<h3>Client side IP geolocation using <a href="http://ipinfo.io">ipinfo.io</a></h3>

<hr/>
<div id="ip"></div>
<div id="country"></div>
<hr/>Full response: <pre id="details"></pre>

JavaScript

$.get("http://ipinfo.io", function (response) {
	console.log('response = '+JSON.stringify(response));
    $("#ip").html("IP: " + response.ip);
    $("#country").html("Country Code: " + response.country);
    $("#details").html(JSON.stringify(response, null, 4));
}, "jsonp");