I want to be able to call the variables I pull from a JSON string in my actual HTML code so in the head of my code I have the following.
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$.getJSON('http://api.openweathermap.org/data/2.5/weather?zip=34285,us&units=imperial', function(data) {
temp = data.main.temp;
weather = data.weather[0].description;
});
</script>
And In the body of my code I have the following
<script>
document.write(temp)
document.write(weath)
</script>
For some reason the variables will not show up. If I try to put the entire function in my body and add the code it works but it rewrites my entire page. How can I get it so that I can reference just the variables and add them to my HTML code.