I am trying to create a one page app that searches weather by a zip code and displays the results. I am accessing a weather database, but I am stuck on how to append a specific json object to my dom
Incomplete javascript
$(function() {
$("#getzip").submit(function() {
var zip_data = $(this).serialize();
$.getJSON("get_weather.php",zip_data, function(data); {
("#output").append(current_obervation.temperature_string); // this is what I want it to do tho obviously incorrect
});
});
})
HTML
<h1>Weather</h1>
<hr />
<form method="get" action="get_weather.php" id="getzip">
<p>
<label for="zip">ZIP:</label>
<input type="text" name="zip" id="zip">
<input type="submit" name="button" id="button" value="Submit" >
</p>
<pre id="output">
</pre>
PHP
<?php
$zip = isset($_GET['zip']) ? $_GET['zip'] : $_POST['zip'];
$weather_data = file_get_contents("http://api.wunderground.com/api/6d125bc5977276ee/conditions/q/{$zip}.json");
echo $weather_data
?>
And a small sample of what the database returns. How would I pinpoint temperature and append it to the dom?
current_observation": {
"image": {
"url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
"title": "Weather Underground",
"link": "http://www.wunderground.com"
"temperature_string": "53.5 F (11.9 C)",
},
}