Parse json data form Youtube api
You're probably looking for jQuery.getJSON(): http://api.jquery.com/jQuery.getJSON/
var url = "http://gdata.youtube.com/feeds/api/videos?q=aNdMiIAlK0g&max-results=1&v=2&alt=jsonc";var title;var description;$.getJSON(url, function(response){ title = response.data.items[0].title; description = response.data.items[0].description;});
getJSON
returns a response with property data
, and data
has a property of items
which is an array. The array only has one item, so we're just using items[0]
, and that item has a property title
and a property description
that we're going to save into our variables.
Hope this helps!
//edit: oops, yeah I thought response would be a better name for the variable, forgot to update the second line
I created a JavaScript function to pull and display a YouTube channel listing (posted the code to StackOverflow). You can find it here: