Tuesday, 1 October 2013

get value from json callback

get value from json callback

I am not trying to append flickr photos to my webpage. I am trying to
retrieve the latitude and longitude values from the json call back.
This is the code I have so far. Nothing happens when I load it into my
browser.
<!DOCTYPE html>
<html>
<head>
<title>Flickr Pie Chart</title>
<meta charset="utf-8">
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#driver").click(function(event){
var apiKey = '[YOUR API KEY]';
var url =
'http://api.flickr.com/services/rest/&method=flickr.photos.search&api_key='
+ apiKey
+'&per_page=500&tags=losangeles&has_geo=1&extras=geo,tags&format=json&jsoncallback=?';
$.getJSON(url, function(data){
//loop through the results with the following function
$.each(data.items, function(i,item){
var geoData +='latitude:' item.latitude + '' + '<br>';
geoData += '' + item.longitude;
$('#results').append(geoData);
});
});
});
});
</script>
</head>
<body>
<div id = "results"></div>
<input type="button" id="driver" value="Load Data" />
</body>
</html>

No comments:

Post a Comment