Monday, July 8, 2013

Get Current City's Temperature using Jquery

<html>
<title>Get Current Location</title>
<head>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script language="JavaScript" type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="JavaScript" type="text/javascript" src="/js/jquery.simpleWeather-2.2.min.js"></script>
<script type="text/javascript">
 jQuery(function() {
     jQuery.simpleWeather({
                zipcode: '',
                woeid: '2357536',
                location: geoip_city(),
                unit: 'f',
                success: function(weather) {
                        jQuery('.container .location-temp').css('background','url('+weather.thumbnail+') no-repeat 0 2px');
                        jQuery('.container .location-temp').css('padding','5px 0px 0 53px');
                        jQuery('.container .location-temp').html(weather.tempAlt+'&deg;C');
                },
                error: function(error) {
                        jQuery("#weather").html('<p>'+error+'</p>');
                }
        });
});
</script>
<head>
<body>
<div>Get Current City's Temperature Please download "jquery.simpleWeather-2.2.min.js"</div>
    <div class="container">
          <div id="weather">
                  Temperature  : <b class="location-temp"></b>
           </div>
         
    </div>
</body>
</html>

No comments:

Post a Comment