Weather acting funny

Hi all,

I decided to go extra pointless with my weather app and make it show the weather on the exact opposite side of the globe (somewhere in the ocean near New Zealand for me).

It works fine most of the time, but then I’ll come back later in the day and the weather portion of it won’t show up at all. I’m guessing this has something to do with using the same API call over and over, but who knows… Maybe one of you fine folk can help. Any other more general comments welcome too, of course!

I find to be unreliable on a good day, almost spiteful on a bad one. If you change your syntax around a bit, you can add an error handler to catch any problems you may have.

$.getJSON('http://...').done(function(weatherData) {
    //... do stuff with weatherData
}).catch(function(error) {
    //... handle the error; won't run if AJAX call was successful

We’ve moved the callback out of the $.getJSON function and into this method called done which, along with catch, is available to you because $.getJSON is a promise.

1 Like

Nice effort. You have done something different

I would suggest you to place weather content at the top, and place the text afterwards.
User should see relevant data first.