Skip to content

Instantly share code, notes, and snippets.

@PolCPP
Created May 29, 2012 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PolCPP/2829250 to your computer and use it in GitHub Desktop.
Save PolCPP/2829250 to your computer and use it in GitHub Desktop.
Get youtube views with jquery
function get_views(video_id) {
var URL = "https://gdata.youtube.com/feeds/api/videos/"+video_id+"?v=2&alt=json";
$.ajax({
type: "GET",
url: URL,
cache: false,
dataType:'jsonp',
success: function(data){
// Add your logic here. As an example it just logs it on the console
console.log(data.entry.yt$statistics.viewCount);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment