Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  99] [ 1]  / answers: 1 / hits: 6481  / 10 Years ago, fri, february 21, 2014, 12:00:00

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


More From » jquery

 Answers
5
$(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


[#47522] Thursday, February 20, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
agustindejonm

Total Points: 738
Total Questions: 84
Total Answers: 84

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
agustindejonm questions
Fri, Jun 25, 21, 00:00, 3 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Sat, May 16, 20, 00:00, 4 Years ago
;