i have a question. i want perline IP address show country use http://ipinfo.io
this html code
<span>192.110.160.11</span><br>
<span>177.67.82.22</span><br>
<span>36.75.102.33</span><br>
my js
document.body.innerHTML = document.body.innerHTML.replace(new RegExp("<span>(.*?)</span>", "g"),"<span id='ip'>$1</span> - <span id='country'>wait..</span>");
var ip = document.getElementById("ip").innerHTML;
$.get("http://ipinfo.io/"+ip, function (response) {
$("#country").html(response.country);
}, "jsonp");
result my js , http://jsfiddle.net/p26uE
192.110.160.11 - US
177.67.82.22 - wait..
36.75.102.33 - wait..
i want result
192.110.160.11 - US
177.67.82.22 - BR
36.75.102.33 - ID
Thanks for everybody who can help me :D
$("span").each(function(i){
var self = this;
var ip = $(this).text();
$.get("http://ipinfo.io/"+ip, function (response) {
$(self).html(ip+"-"+response.country);
}, "jsonp");
});
Check this
JSFIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With