Refresh JavaScript section only? -
Refresh JavaScript section only? -
i have section of javascript displays current temperature, not update temperature changes. there way have section of javascript update on timer?
edit: sorry, here's code (not created me).
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> // javascript go here $(function(){ // specify zip/location code , units (f or c) var loc = '10001'; // or e.g. spxx0050 var u = 'f'; var query = "select item.condition weather.forecast location='" + loc + "' , 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; $('#wxicon').css({ backgroundposition: '-' + (61 * info.code) + 'px 0' }).attr({ title: info.text }); $('#wxicon2').append('<img src="http://l.yimg.com/a/i/us/we/52/' + info.code + '.gif" width="40" height="40" title="' + info.text + '" />'); $('#wxtemp').html(info.temp + '°' + (u.touppercase())); }; $.ajax({ url: url, datatype: 'jsonp', cache: true, jsonpcallback: 'wxcallback' }); }); </script>
name function (instead of using $(function(){...
) getweather
and somewhere outside ...
setinterval(getweather,10000)
try : http://codepen.io/anon/pen/bvydh
javascript
Comments
Post a Comment