Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) AJAX and APIs Create a callback function

AJAX and APIs Challenge Task 3 of 3

I'm stuck on the final step. Not sure how to do the following:

Finally, to insert the temperature into the div, use jQuery's text() method. You'll need to pass the temperature into this method. The Open Weather Map API returns an object with the property main; that property holds another object with the property"temp". To access the temperature, use dot syntax, like this:weatherReport.main.temp

$(document).ready(function() {
  var weatherAPI =http://api.openweathermap.org/data/2.5/weather’;
  var data = {
    q:Portland,OR,
    units: metric
  };
  function showWeather(weatherReport){
  $(‘#temperature).text(weatherReport.main.temp);
  };
};// end of ready
Ken Alger
Ken Alger
Treehouse Teacher

Edited for Markdown.

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Kerry;

You are extremely close on this challenge task. A few syntax issues. A) in the #temperature selector you appear to be using backticks. Either single or double quotes are needed. B) You don't want to designate the dot syntax of weatherReport.main.temp as a string, so you can remove those quotes as well, also those appear to be backticks.

Those changes should do the trick.

Ken

Hi Ken,

Something weird is going on with those quotes. I don't think they're backticks because they would all be going the same way.

All the quotes including the double ones in the data object look like the slanted quotes or curly quotes you might get from a word processor.

You can compare here:

“metric”  // copied from question
"metric" // typed from my keyboard

Not sure how the starter code got those quotes.

Kerry, you'll have to fix all of the quotes throughout the code as well as fix B) that Ken wrote.

I also noticed when testing your code that you somehow lost the closing parenthesis on .ready()

It was in the last line of the starter code like this: });

Your last line doesn't include it.