我正在尝试从外部域获取预测信息,这似乎还不起作用。Angular 和 jQuery 都已加载,但 HTML 中没有显示任何内容。Chrome 也不会报告错误消息。
var currentCityread = "Eindhoven";
var api1 = 'http://api.openweathermap.org/data/2.5/forecast/daily?q='+currentCityread+'&cnt=10&mode=json&units=metric&APPID=000000000000000&callback=?';
var api2 = 'http://api.openweathermap.org/data/2.5/weather?q='+currentCityread+'&mode=json&units=metric&APPID=000000000000000&callback=?'
function ReadJson($scope) {
$.ajax({
dataType: "json",
url: api1,
}).done(function (output) {
$scope.jsonTotal = output.list[0].temp.day+output.list[1].temp.day+output.list[2].temp.day+output.list[3].temp.day+output.list[4].temp.day+output.list[5].temp.day+output.list[6].temp.day+output.list[7].temp.day+output.list[8].temp.day+output.list[9].temp.day;
$scope.jsonCalcu = Math.round($scope.jsonTotal / 10);
$scope.jsonCurrent = Math.round(output.list[0].temp.day);
$scope.jsonCurrent2 = Math.round(output.list[1].temp.day);
$scope.jsonCurrenticon2 = output.list[1].weather[0].icon;
$scope.jsonCurrent3 = Math.round(output.list[2].temp.day);
$scope.jsonCurrenticon3 = output.list[2].weather[0].icon;
});
$.ajax({
dataType: "json",
url: api2,
}).done(function (outputcurrent) {
$scope.jsonCurrenticon = outputcurrent.weather[0].icon;
});
}