Skip to content

Instantly share code, notes, and snippets.

@drews256
Created November 7, 2018 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drews256/88077a7c55dbbe7cb5cbc8f3b8b8dbac to your computer and use it in GitHub Desktop.
Save drews256/88077a7c55dbbe7cb5cbc8f3b8b8dbac to your computer and use it in GitHub Desktop.
$(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