-1
I got the following
var res;
$(window).load(function(){
$.get("http://ipinfo.io", function (response) {
res = JSON.stringify(response, null, 4);
res = res.replace(/:/g, '');
res = res.replace(/\"/g, '');
res = res.replace(/\n/g, '');
res = res.replace("{", "");
res = res.replace("}", "");
res = res.replace("ip", "");
res = res.replace("hostname", "");
res = res.replace("city", "");
res = res.replace("region", "");
res = res.replace("country", "");
res = res.replace("loc", "");
res = res.replace("org", "");
res = res.replace(/ /g, '');
$("#dados").html("Dados: " + res);
}, "jsonp");
});
res = JSON.stringify(Sponse, null, 4); before applying the various Places returns
{
"ip": "187.155.67.279",
"hostname": "b1c33eb3.virtua.com.br",
"city": "Leblon",
"region": "Rio de Janeiro",
"country": "BR",
"loc": "-22.8244,-43.0353",
"org": "AS28573 CLARO S.A."
}
And after the catataus of Places returns
187.155.67.279,b1c33eb3.virtua.com.br,Leblon,Rio de Janeiro,BR,-22.8244,-43.0353,AS28573 CLARO S.A.
So the question is: How to avoid this heap of Replaces, and assign the result to the variable res
It’s a json, maybe it’s simpler to parse and iterate the elements and play in a string.
– rray
yes, but how do you do it?
– user60252