"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, April 2, 2011

Getting IP address through JQuery

Hi *.*,
In this tips,show how we could get the client IPAddress  with JQuery. Becase we know to get the client PC IPAddress usign ASP.NET

Using Server Side Code

Request.ServerVariables["REMOTE_ADDR"];

Using Jquery
$(function() {
    $('a').click(function()
{
    $.getJSON("http://jsonip.appspot.com?callback=?",function(ipadd){
        alert( "Your IPAddress is : " + ipadd.ip);
    });
     });
});

in above code,i have done a simple query the IPAddress using JSON to another IPaddress provider server. the callback function will return the Your PC IP Address.
Have a nice day... 'N happy Coding :)

No comments: