Weather Viewer accessing json data for toggle button

Here is my current pen of the project. I’m trying to complete the user story for a button that toggles data between fahrenheit and celsius. However, I’m confused on how I am supposed to access data for a button outside of the ajax call. I see people setting var fahrenheit=response.main.temp for their buttons but how do you do so when you can only access the data inside the ajax call?

You can take data directly from html DOM, for example if you store your farenheit data in

> <p id="farh" > 78 </p>


you can take its value and manipulate like this $("#farh").val();

Pretty sure that .val doesn’t work for asynchronous data.

you can do text() than it works.