Una simple llamada AJAX a su servidor, y luego la lógica en el servidor para obtener la dirección IP debería hacer el truco.
$.getJSON('getip.php', function(data){
alert('Your ip is: ' + data.ip);
});
Luego, en php que podría hacer:
<?php
/* getip.php */
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
print json_encode(array('ip' => $ip));
y pruébelo. Gracias. – Wondering
genial, pero la aplicación está por encima de la cuota :( –
'jsonip.appspot.com' también aparentemente admite' CORS' y 'JSONP'. – hippietrail