2017-07-20 9 views
0

私はLocal Weatherをやっています。私はそれをテストすると、それは私のAndroidデバイスと私のラップトップで働いた。しかし、私のデスクトップデバイスは動作せず、同じWi-Fiを使用しています。私の英語には申し訳ありません。 私のHTML:My Weather Apiは別のデバイスでは動作しません

$(document).ready(function() { 
 
    $.ajax({ 
 
    url: "http://api.openweathermap.org/data/2.5/weather", 
 
    jsonp: "callback", 
 
    dataType: "jsonp", 
 
    data: { 
 
     id: "1580578", 
 
     APPID: "1d6bb0530f112b543e38e98b7f2b3d36" 
 
    }, 
 
    success: function(data) { 
 
     var weatherType = data.weather[0].description; 
 
     var kelvin = data.main.temp; 
 
     var windspeed = data.wind.speed; 
 
     var city = data.name; 
 
     var doC = kelvin - 273; 
 

 
     $(".name").html(city); 
 
     $(".doC").html(Math.floor(doC)); 
 
     $(".windspeed").html(windspeed); 
 
     $(".weatherType").html(weatherType); 
 
     $('.current').html('<img src="http://openweathermap.org/img/w/' + data.weather[0].icon + '.png" /> ' + data.weather[0].main); 
 
    } 
 
    }); 
 
});
body { 
 
    margin-top: 100px; 
 
    background: url('http://wallpapercave.com/wp/QGsncry.jpg'); 
 
} 
 

 
#white { 
 
    color: white; 
 
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
<div class="container-fluid> 
 
    <div class=" row "> 
 
    <h1 style="text-align: center" id="white"> Weather</h1> 
 
    <center> 
 
     <div class="current"></div> 
 

 
     <table style="text-align: center"> 
 
     <tr> 
 
      <th> 
 
      <h3> Description: </h3> 
 
      </th> 
 
      <th> 
 
      <h3 style="text-align: center" class="weatherType btn btn-default"> </h3> 
 
      </th> 
 
     </tr> 
 
     <tr> 
 
      <th> 
 
      <h3> City: </h3> 
 
      </th> 
 
      <th> 
 
      <h3 style="text-align: center" class="name btn btn-default"> </h3> 
 
      </th> 
 
     </tr> 
 

 
     <tr> 
 
      <th> 
 
      <h3> Temperature: </h3> 
 
      </th> 
 
      <th> 
 
      <h3 style="text-align: center" class="doC btn btn-default"> </h3> 
 
      </th> 
 
     </tr> 
 
     <tr> 
 
      <th> 
 
      <h3> WindSpeed: </h3> 
 
      </th> 
 
      <th> 
 
      <h3 style="text-align: center" class="windspeed btn btn-default"> </h3> 
 
      </th> 
 
     </tr> 
 
     </table> 
 
    </center> 
 
    </div> 
 
</div>

+4

ドをロードするように依頼HTTPS.手段なしにあなたのウェブサイトをロードするためにそれらを求めますあなたはコンソールのエラーを取得しますか?どのように "動作しません"? – krillgar

+0

'th'の代わりに' td'を使うつもりでしたか?それとも意図的にやったの? – Ionut

+0

'class =" container-fluid'に閉じ引用がありません –

答えて

0

問題がhttpsです。あなたはhttps://testmyblog.000webhostapp.com/HTTPS上のアプリを主催しているし、あなたのAPIがhttp://api.openweathermap.org/ので、最近のブラウザが原因Mixed ContentにエラーがスローされますHTTP上にあるとして

。あなたのウェブサイトがHTTPSにある場合は、http非セキュアドメインからリソースを読み込むことはできません。これはブラウザ固有の機能であるため、リクエストはブラウザ自体によってブロックされます。

あなたの友人がどんな問題に直面しているのであれば、...

http://testmyblog.000webhostapp.com/

の代わりに、HTTPSバージョン/

+0

@NghĩaLêはhttp 'あなたのAPIが' http'にあるので、 'https'ではありません。 –

+0

ええ、私の問題は解決しました。 – Snow

関連する問題