JS cannot get IP address with jquery across domains

  • 2020-03-30 03:44:37
  • OfStack

Get IP address, JS can also get client IP address, you know JS can not cross the domain, so here with the help of jquery, really can achieve IP address, the code is as follows, has passed the test:


<script language="javascript" src="//www.jb51.net/jslib/jquery/jquery.js"></script> 
<script language="javascript"> 
jQuery(function($){ 
var url = 'http://chaxun.1616.net/s.php?type=ip&output=json&callback=?&_='+Math.random(); 
$.getJSON(url, function(data){ 
alert(data.Ip); 
}); 
}); 
</script>

Related articles: