Powered By Blogger

Thursday, November 7, 2013

To Get IP Address using jquery

<head runat="server">
    <title></title>
    <script src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="http://api.easyjquery.com/easyjquery.js"></script>
    <script type="text/javascript">
        jQuery.noConflict();
        jQuery(document).ready(function () {
            var aa;
            var ab;
            jQuery.getJSON("http://api.easyjquery.com/ips/?callback=?",
             function (data) {
                 jQuery("#info").html(data.CityLatitude);
                 jQuery("#info1").html(data.CityLongitude);
                 aa = data.CityLatitude;
                 ab = data.CityLongitude;

                 jQuery.ajax({
                     type: 'Get',
                     url: 'http://where.yahooapis.com/geocode?location=' + aa + ',' + ab + '&flags=J&gflags=R&appid=zHgnBS4m',
                     success: function (data) {
                         alert(data);
                     
                         $.each(data, function (i, item) {
                             alert(item.result);
                             jQuery("#info2").html(item.result);
                         })
                     }

                 })


                 // jQuery.getJSON("http://where.yahooapis.com/geocode?location=" + aa + "," + ab + "&flags=J&gflags=R&appid=zHgnBS4m",
                 //function (data) {                  
                 //    if (data != null && data != "") {
                 //        alert(data);
                 //        $.each(data, function (i, item) {
                 //            alert(item.result);
                 //            jQuery("#info2").html(item.result.woeid);
                 //        })
                 //    }
                 //});
             });



            jQuery(function () {

                // Specify the ZIP/location code and units (f or c)
                var loc = '10001'; // or e.g. SPXX0050
                var u = 'c';

                var query = "SELECT item.condition FROM weather.forecast WHERE location='" + loc + "' AND u='" + u + "'";
                var cacheBuster = Math.floor((new Date().getTime()) / 1200 / 1000);
                var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&_nocache=' + cacheBuster;

                window['wxCallback'] = function (data) {
                    var info = data.query.results.channel.item.condition;
                    jQuery('#wxIcon').css({
                        backgroundPosition: '-' + (61 * info.code) + 'px 0'
                    }).attr({
                        title: info.text
                    });
                    jQuery('#wxIcon2').append('<img src="http://l.yimg.com/a/i/us/we/52/' + info.code + '.gif" width="34" height="34" title="' + info.text + '" />');
                    jQuery('#wxTemp').html(info.temp + '&deg;' + (u.toUpperCase()));
                };

                jQuery.ajax({
                    url: url,
                    dataType: 'jsonp',
                    cache: true,
                    jsonpCallback: 'wxCallback'
                });

            });
        });


    </script>
</head>

No comments:

Post a Comment