Try this:
$.getJSON("http://smart-ip.net/geoip-json?callback=?", function(data){
alert(data.host);
});
Question
Is it possible to get the ip address of the user (visitor of my website) without using server side language like PHP?
I have a problem while using the server language (PHP) because of load balancer for my server. I tried http_x_forwared_for that is also not retrieving the perfect ip address.
Solution
Try this:
$.getJSON("http://smart-ip.net/geoip-json?callback=?", function(data){
alert(data.host);
});
OTHER TIPS
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
IN PHP :)