How to get client IP address using jQuery

前端 未结 4 1441

I want to know how to get client IP address using jQuery?

Is it possible? I know pure javascript can\'t, but got some code using JSONP from Stack Overfl

4条回答
  •  甜味超标
    2020-11-27 03:40

    A simple AJAX call to your server, and then the serverside logic to get the ip address should do the trick.

    $.getJSON('getip.php', function(data){
      alert('Your ip is: ' +  data.ip);
    });
    

    Then in php you might do:

     $ip));
    

提交回复
热议问题