2016-12-30 6 views
0

リンクを確認しても問題はありません。これは私がコンソールに取得していますエラーです:

がGET http://localhost:60789/api.openweathermap.org/data/2.5/weather?q=Tel%20Aviv%2CIL&units=metric&APPID=the与えられた数404(見つかりません)

$(document).ready(function() { 
    var getIP = 'http://ip-api.com/json'; 
    var openWeatherMap = 'api.openweathermap.org/data/2.5/weather' 

    $.getJSON(getIP).done(function(location) { 
     $.getJSON(openWeatherMap, { 
      q: location.regionName + "," + location.countryCode, 
      units: 'metric', 
      APPID: 'Here iam giving my appid' 
     }).done(function (weather) { 
       console.log(weather);     
      $('ul:first-child').html(weather.name + "," + weather.sys.country); 
     }) 
    }); 
}); 
+0

GETリクエストで明らかに問題が示されています。誰かが絶対リンクを使用していません。 – epascarello

答えて

4

あなたはopenWeatherMap URLにhttp://接頭辞を逃しています。このため、ブラウザが前に付加がそれにhttp://localhost:60789/ので、あなたが提供しているパスは、現在のURLに相対的なものであると仮定し - したがって、404

問題を解決するには、単にURLにhttp://を付加あなたのことは絶対にする:

var openWeatherMap = 'http://api.openweathermap.org/data/2.5/weather'; 
+0

今これを取得: –

関連する問題