这是我的代码打击wunderground天气,他都准备工作正常,但我想做出改变,这个改变很好从自动检测到自动完成api,我尝试但得到错误,我只是一些编辑我代码更改为自动完成API。
jQuery(document).ready(function(weather) {
$.ajax({
url : "http://api.wunderground.com/api/eb7a37c339cfd624/geolookup/conditions/forecast10day/lang:AR/q/autoip.json",
dataType : "jsonp",
timeout: 8000,
error: function(jqXHR) {
if(jqXHR.status==0) {
alert(" يرجى تØقيق من اتصالك بالانترنت ")
}
},
success : function(data) {
var degree = data.current_observation.wind_degrees;
var direction = check(degree);
///information //
var html = ' <div class="ui-grid-solo"> <div class="ui-block-a">';
html += '<h1 class="text-center">'+ data.current_observation.temp_c + '</h1>'
html += '<h4 class="text-center">'+ data.current_observation.display_location.city + '</h4>'
html += '<h4 class="text-center">'+ data.current_observation.observation_time + '</h4>'
html += '</div></div>';
$("#temp").append(html).hide().fadeIn("slow");
///forecast now //
var html = '<div class="ui-grid-a"><div class="ui-block-a">';
html += ''+ direction + ''
html+= '<h3 class="text-center"> بسرعة '+data.current_observation.wind_kph + ' عقدة </h3></div>'
html+= ' <div class="ui-block-b"><h3 class="text-center">الاجواء '+ data.current_observation.weather +'</h3><table style="width: 100%"><tr style="text-align: -moz-center;"><td style="width: 1%"><span style="width: 10%; text-align: center;text-align: center; font-size: 25px;"class="text-center">'+ data.current_observation.feelslike_c +'</span></td><td style="width: 19%"><span style="font-size:20px;">شعور بها</span><img src="http://icons.iconarchive.com/icons/iconsmind/outline/32/T-Shirt-icon.png" style="float: right; width: 25px;" /></td></tr></table><table style="width: 100%"><tr><td style="float: right;font-size:large;direction:rtl"> الرطوبة '+ data.current_observation.relative_humidity +'</td><td style="width: 50px"><img src="http://icons.iconarchive.com/icons/icons8/windows-8/24/Science-Humidity-icon.png" /style="float: right;"></td></tr></table> <table style="width: 100%"><tr><td style="font-size: 18px;"> ضغط جوي '+ data.current_observation.pressure_mb +'</td><td style="width: 25px"><img src="http://icons.iconarchive.com/icons/icons8/ios7/24/Science-Pressure-icon.png" /style="float: right;"></td></tr></table>'
html += '</div></div>';
$("#news").append(html).hide().fadeIn("slow");
//wind//
var html = '<div class="ui-grid-a"><div class="ui-block-a">';
html += ''+ direction + ''
html+= '<h3 class="text-center"> بسرعة '+data.current_observation.wind_kph + ' عقدة </h3></div>'
html+= ' <div class="ui-block-b"><h3 class="text-center"> بسرعة '+data.current_observation.wind_kph + ' عقدة </h3>'
html += '</div></div>';
$("#wind").append(html).hide().fadeIn("slow");
///10days///
var dayArray = data.forecast.txt_forecast['forecastday'];
var html = '<div>';
for(var i=0; i<dayArray.length; i+=2)
html += '<h3>'+data.forecast.txt_forecast.forecastday[i]['title']+ " : " +data.forecast.txt_forecast.forecastday[i]['fcttext_metric']+'</h3></div>'
html += '</div>';
$("#10").append(html).hide().fadeIn("slow");
}
});
});