How to get ip address in jquery?

By Hardik Savani | June 8, 2016 | | 54296 Viewer | Category : Javascript jQuery


you can get ip address in jquery using getJSON(). If you need to get ip address in your js file you can get easily. In this example you can see how to get ip address in jquery. So let's try with this...

Example

<html lang="en">

<head>

<title>Jquery - get ip address</title>

<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>

</head>

<body>


<h1>Your Ip Address : <span class="ip"></span></h1>


<script type="text/javascript">

$.getJSON("http://jsonip.com?callback=?", function (data) {

$(".ip").text(data.ip);

});

</script>


</body>

</html>




Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: