I want to know any website webpage where I can send user IP address and receive their country/place as plain/text.

For reference, I have demonstrated in code snippet below.

I tried executing following code to rescieve user IP.

<script type="text/javascript" src="https://l2.io/ip.js?var=userip"></script>

...

<script type="text/javascript">
  document.write("Your IP is :", userip);
</script>

$.post("domain.sdm/page", {
    "ip": "123.234.345"
}, function(dat,suc) {
    alert("Your country is: "+ dat);
});

1 Answers

0
Whitewolf3131 On Best Solutions

A good website that does that would be https://iplocation.com/

If you send an IP address in a POST request you will receive a bundle with a lot of info about the IP address, including the city and the country.

Also the ip address is composed of 4 bytes so that means 4 numbers going up to 2^8, not 3.

!Disclaimer! You have to pass the URL through https://cors-anywhere.herokuapp.com beacause of the CORS policy, or else your request will be blocked because you would do a request from another domain.

$.post("https://cors-anywhere.herokuapp.com/https://iplocation.com", {
    "ip": "124.84.42.76" //for example but watch out some ip addresses might not exist
}, function(dat,suc) {
    alert("Your country is: "+ dat.country_name);
});