Edit in JSFiddle

$(function() {
  $("#submit").click(function() {
    if ($('#ip').val()) {
      var ip = $('#ip').val();

      // the request will be to http://www.geoplugin.net/json.gp?ip=my.ip.number but we need to avoid the cors issue, and we use cors-anywhere api.

      $.getJSON("https://cors-anywhere.herokuapp.com/http://www.geoplugin.net/json.gp?ip=" + ip, function(response) {
        console.log(response);
        // output an object which contains the information.
        $("#content").html("Hello visitor from " + response.geoplugin_countryName);

      });
    } else {
      alert("Please provide a IP");
    }
  });
});
<p>
  If you don't know your ip get it here quickly : <a href="http://www.whatsmyip.org/">http://www.whatsmyip.org/</a>
</p>
<input type="text" id="ip" />
<input type="button" value="Get country of IP" id="submit" />
<br>
<div id="content">

</div>