How to get client IP address using jQuery

前端 未结 4 1435

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条回答
  •  Happy的楠姐
    2020-11-27 03:23

    function GetUserIP(){
      var ret_ip;
      $.ajaxSetup({async: false});
      $.get('http://jsonip.com/', function(r){ 
        ret_ip = r.ip; 
      });
      return ret_ip;
    }
    

    If you want to use the IP and assign it to a variable, Try this. Just call GetUserIP()

提交回复
热议问题