assets/JS/script.js
// ajax call to the Open Weather API to get current data on selected city
ajax call to the Open Weather API to get current data on selected city
ajax call to the Open Weather API to get current data on selected city
function weather(city) {
    var queryURL = "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&appid=" + apiKey + "&units=imperial";
    $.ajax({
        url: queryURL,
        method: "GET"
    }).then(function(response) {
        console.log(response);
        $("#selectedCity").removeClass("d-none");
        var temp = (response.main.temp);
        var date = moment().format("MM/DD/YYYY");
        var weatherIcon = (response.weather[0].icon);
        var URL = "https://openweathermap.org/img/w/" + weatherIcon + ".png";
        $("#cityName").html(response.name + " " + date + "<img id= 'wicon' src= '' alt= 'Weather Icon'>");
        $("#wicon").attr("src", URL);
        $("#temp").text("Temperature: " + temp.toFixed(2) + "°F");
        $("#rh").text("Humidity: " + response.main.humidity + "%");
        $("#wind").text("Wind: " + response.wind.speed + "mph");
        uvIndex(response.coord.lat, response.coord.lon);
    })
}
function weather ( city ) { var queryURL = "https://api.openweathermap.org/data/2.5/weather?q=" + city + "&appid=" + apiKey + "&units=imperial" ; $ . ajax ( { url : queryURL , method : "GET" } ) . then ( function ( response ) { console . log ( response ) ; $ ( "#selectedCity" ) . removeClass ( "d-none" ) ; var temp = ( response . main . temp ) ; var date = moment ( ) . format ( "MM/DD/YYYY" ) ; var weatherIcon = ( response . weather [ 0 ] . icon ) ; var URL = "https://openweathermap.org/img/w/" + weatherIcon + ".png" ; $ ( "#cityName" ) . html ( response . name + " " + date + "<img id= 'wicon' src= '' alt= 'Weather Icon'>" ) ; $ ( "#wicon" ) . attr ( "src" , URL ) ; $ ( "#temp" ) . text ( "Temperature: " + temp . toFixed ( 2 ) + "°F") ; $ ( "#rh" ) . text ( "Humidity: " + response . main . humidity + "%" ) ; $ ( "#wind" ) . text ( "Wind: " + response . wind . speed + "mph" ) ; uvIndex ( response . coord . lat , response . coord . lon ) ; } ) }
ajax call to the Open Weather API to get current data on selected city
ajax call to the Open Weather API to get current data on selected city