0

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

Chakotay
  • 409
  • 1
  • 7
  • 17

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,315
  • 2
  • 28
  • 49
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
  • 992
  • 8
  • 19