Created
November 7, 2018 23:00
-
-
Save drews256/88077a7c55dbbe7cb5cbc8f3b8b8dbac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$("#weather_button").click(function(e) { | |
console.log(e) | |
e.preventDefault(); | |
$.ajax({ | |
type: "POST", | |
data: 'json', | |
url: 'https://api.openweathermap.org/data/2.5/weather?zip=98229,us&appid=539756b83366c299af98e440614ce980', | |
success: function(result) { | |
console.log(result) | |
$( ".city-name" ).text(result.name); | |
$(".weather-main").text(result.weather && result.weather[0] && result.weather[0].main) | |
$(".description").text(result.weather && result.weather[0] && result.weather[0].description) | |
}, | |
error: function(result) { | |
console.log('error', result) | |
$(".error").text(result.error) | |
} | |
}); | |
}); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment