Weather Viewer accessing json data for toggle button

Weather Viewer accessing json data for toggle button
0

#1

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?


#2

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();


#3

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


#4

you can do text() than it works.