0

Would Javascript be good for this? Can JavaScript even do this? If Javascript is not good for this purpose, how about PHP?

Lexus de Vinco
  • 447
  • 2
  • 7
  • 20

2 Answers2

1

jQuery version. conversion to standard Javascript is straightforward

$.get("http://ip-api.com/json", function(response) {
    console.log(response.country);
});
Stephen Thomas
  • 13,843
  • 2
  • 32
  • 53
0

You could use http://ipinfo.io API for this.

$.get("http://ipinfo.io", function (response) {
    console.log(response.country)
}, "jsonp");

http://jsfiddle.net/Em6nU/

Chris
  • 1,020
  • 10
  • 19