<html>
<script>
 
var xhr = new XMLHttpRequest();
xhr.open('GET', "http://ipinfo.io/json", true);
xhr.send();
 
xhr.onreadystatechange = processRequest;
 
function processRequest(e) {
 
	if (xhr.readyState == 4 && xhr.status == 200) {
        var response = JSON.parse(xhr.responseText);
           alert(response.ip);
    }
}

</script>
</html>

  

posted on 2019-01-04 11:49  小白闯天下  阅读(230)  评论(0编辑  收藏  举报