How to get client ip address in javascript of jquery?
In this post we will give you information about How to get client ip address in javascript of jquery?. Hear we will give you detail about How to get client ip address in javascript of jquery?And how to use it also give you demo for it if it is necessary.
Sometime you need to save visitor’s ip address using javascript or jquery.
jQuery handle JSONP so it’s very easy to get client ip address by passing url formatted with the callback=? parameter with $.getJSON
request.
You can also use $.get
request to get ip address with data type jsonp.
- <htmllang="en">
- <head>
- <title>How to get client ip address in javascript or jquery?</title>
- <scripttype="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
- </head>
- <body>
- <h1>Your Ip Address (jsonip.com) : </h1>
- <spanid="ip"></span>
- <h1>Your Ip Address (ipinfo.com) : </h1>
- <spanid="ip1"></span>
- <scripttype="text/javascript">
- $.getJSON("http://jsonip.com?callback=?", function (response) {
- $("#ip").text(response.ip);
- });
- $.get("http://ipinfo.io", function(response) {
- $("#ip1").text(response.ip);
- }, "jsonp");
- </script>
- </body>
- </html>
<html lang="en"> <head> <title>How to get client ip address in javascript or jquery?</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script> </head> <body> <h1>Your Ip Address (jsonip.com) : </h1> <span id="ip"></span> <h1>Your Ip Address (ipinfo.com) : </h1> <span id="ip1"></span> <script type="text/javascript"> $.getJSON("http://jsonip.com?callback=?", function (response) { $("#ip").text(response.ip); }); $.get("http://ipinfo.io", function(response) { $("#ip1").text(response.ip); }, "jsonp"); </script> </body> </html>
Hope this code and post will helped you for implement How to get client ip address in javascript of jquery?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs