Weather app Firefox

Weather app Firefox
0.0 0

#1

Hello,

I am working on Weather App and I am having problems trying to make it work in Firefox. App works in Safari.

Here is my code:

var lat;
var lon;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) { 
  lat = String(position.coords.latitude.toFixed(2));
  lon = String(position.coords.longitude.toFixed(2));
                                                             
$("#geo").html(lon);
});
}



$(document).ready(function(){

         $.ajax({
      url: "http://api.openweathermap.org/data/2.5/weather?APPID=XXXXXXXXXXXXX",
data: {lat: lat,lon: lon},
      success: function(x) {
           
                $("section").html("<strong>" + x.main.temp + "</strong>" + " " + x.weather[0].icon + " " + x.weather[0].description + x.name + " " + x.main.humidity + " " + x.wind.speed);
      }
            });
        });

And here are the errors that I get in Firefox https://gyazo.com/c03a45dc5007d16bdacf925cec627aa4

"NetworkError: 500 Internal Server Error - http://api.openweathermap.org/data/2.5/weather?APPID=XXXXXXXX"
weather…154e3e2
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://api.openweathermap.org/data/2.5/weather?APPID=XXXXXXX. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).


#3

Thank you very much! Nice solution and great explanation :slight_smile: