私はプロジェクトを完了しています.Githubページにアップロードすると機能しません。スクリプト、外部リンクフォント、APIデータは持ち込まれません。 APIはHTTPのみをサポートし、GithubページはHTTPSのみを受け入れます。 APIを変更することなく、どのような方法で? APIはOpenweathermapです。Openweathermap API on Githubpages
$(document).ready(function(){
var temp = $('.temperature');
var APIKEY = ';
var loc = $('#search').val();
function updateByCity(loc){
\t var url = "http://api.openweathermap.org/data/2.5/weather?q=" + loc + "&APPID=" + APIKEY;
\t sendRequest(url);
}
function k2f(k){
return Math.round(k*(9/5)-459.67);
}
function ascii(a){
\t return String.fromCharCode(a);
}
$('.enter').click(function(event){
event.preventDefault();
var loc = $('#search').val();
var url = "http://api.openweathermap.org/data/2.5/weather?q=" + loc + "&APPID=" + APIKEY;
\t console.log(url);
\t var xmlhttp = new XMLHttpRequest();
\t xmlhttp.onreadystatechange = function(){
\t \t var url = "http://api.openweathermap.org/data/2.5/weather?q=" + loc + "&APPID=" + APIKEY;
\t \t console.log("lol");
\t var data = JSON.parse(xmlhttp.responseText);
\t var datatext = data.id;
\t var name = data.name;
\t \t var locname = name;
\t \t var temptext = k2f(data.main.temp) + ascii(176) + "F";
\t \t console.log(temp);
\t \t console.log(url);
\t \t $('.temperature').text(temptext);
\t $('.city').text(name);
\t };
\t xmlhttp.open("GET", url, true);
\t xmlhttp.send();
});
SOにAPIキーを投稿したくない場合があります。 – Timo
無料のAPIですが、わかりました。 – William