Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4081154
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:01:26+00:00 2026-05-20T18:01:26+00:00

<script type= text/javascript> var url = http://gdata.youtube.com/feeds/api/videos/VA770wpLX-Q?v=2&amp;alt=json-in-script&amp;callback=; var title; var description; var viewcount; var

  • 0
    <script type= "text/javascript">
var url = "http://gdata.youtube.com/feeds/api/videos/VA770wpLX-Q?v=2&amp;alt=json-in-script&amp;callback=";
var title;
var description;
var viewcount;
var views;
var author;
$.getJSON(url,
    function(data){
        title = data.entry.title.$t;
        description = data.entry.media$group.media$description.$t;
        viewcount = data.entry.yt$statistics.viewCount;
        views = numberFormat (viewcount);
        author = data.entry.author[0].name.$t;
        listInfo (title,description,author,views);
});

</script>

So thats my code to get information from a single video, after the info is received it calls this function to display it:

    <script type="text/javascript">
function listInfo (title,description,author,views) {
    var html = ['<dl>'];
      html.push('<dt>','<span class="titleStyle">', title,'</span><span class="descriptionStyle">',description, '</span><span class="authorStyle">',author,'</span><span class="viewsStyle">',' Views:',views,'</span></dt>');

    html.push('</dl>');
    document.getElementById("agenda").innerHTML = html.join("");
}
     function numberFormat(nStr,prefix){
    var prefix = prefix || '';
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    return prefix + x1 + x2;
}
  </script>

After that it puts the definition List into a div, which I have inside a table

<table width="485"><tr><td><div id="agenda"></div></td></tr></table>

all of this information is found in the body, I can’t seem to get it to work, I’ve been trying for a week now, and I can’t find any way to make it work

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:01:26+00:00Added an answer on May 20, 2026 at 6:01 pm

    Since the youtube API does not allow more than 50 comments to be returned on a single request, you’ll need to add a URL parameter called “start-index”, which tells youtube that you want to get comments from there onwards. Below is an example. I’ve made it so that as long as the response JSON returns 50 comments, it calls the function again for the next 50 comments.

    <html>
    <head>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
            <script type= "text/javascript">
            function getYouTubeInfo() {
                    $.ajax({
                            url: "http://gdata.youtube.com/feeds/api/videos/<?php echo $_GET['v']; ?>?v=2&alt=json",
                            dataType: "jsonp",
                            success: function (data) { parseresults(data); }
                    });
            }
    
            function parseresults(data) {
                    var title = data.entry.title.$t;
                    var description = data.entry.media$group.media$description.$t;
                    var viewcount = data.entry.yt$statistics.viewCount;
                    var author = data.entry.author[0].name.$t;
                    $('#title').html(title);
                    $('#description').html('<b>Description</b>: ' + description);
                    $('#extrainfo').html('<b>Author</b>: ' + author + '<br/><b>Views</b>: ' + viewcount);
                    getComments(data.entry.gd$comments.gd$feedLink.href + '&max-results=50&alt=json', 1);
            }
    
            function getComments(commentsURL, startIndex) {
                    $.ajax({
                            url: commentsURL + '&start-index=' + startIndex,
                            dataType: "jsonp",
                            success: function (data) {
                            $.each(data.feed.entry, function(key, val) {
                                    $('#comments').append('<br/>Author: ' + val.author[0].name.$t + ', Comment: ' + val.content.$t);
                            });
                            if ($(data.feed.entry).size() == 50) { getComments(commentsURL, startIndex + 50); }
                            }
                    });
            }
    
            $(document).ready(function () {
                    getYouTubeInfo();
            });
            </script>
            <title>YouTube</title>
    </head>
    <body bgcolor="grey">
            <div align="center">
                    <br/><br/>
                    <div id="title" style="color: #dddddd">Could not find a title</div><br/>
                    <iframe title="Youtube Video Player" width="640" height="390" src="http://www.youtube.com/embed/<?php echo $_GET['v']; ?>?fs=1&autoplay=1&loop=0" frameborder="0" allowfullscreen style="border: 1px solid black"></iframe>
                    <br/><br/>
                    <div id="description" style="width:400px; background-color: #dddddd; font-size:10px; text-align:left;">Could not find a description</div>
                    <div id="extrainfo" style="width:400px; background-color: #dddddd; font-size:10px; text-align:left;">Could not find extra information</div>
                    <div id="comments" style="width:400px; background-color: #dddddd; font-size:10px; text-align:left;">Could not find comments</div>
            </div>
    </body>
    </html>
    

    If you have any more questions or you get stuck with this code, don’t hesitate to ask again 🙂

    Good luck,
    Tom

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<script type=text/javascript> function testing() { $.ajax({ type: POST, url: testing.php, data: call=+$(#abc).val(), success: function(msg){
So I have a URL like: http://maps.googleapis.com/maps/api/geocode/json?&sensor=false&address=1330+SW%203rd%20Ave,%20Portland,%20OR But it returns just JSON. Im looking
I have written down the following code: var url = http://maps.googleapis.com/maps/api/geocode/json?latlng=+position.coords.latitude+,+position.coords.longitude+&sensor=false&callback=parseMe; console.log('URL is --
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
look at this code, <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script> function change() {
function getTime(zone, success) { var url = 'http://json-time.appspot.com/time.json?tz=' + zone, ud = 'json' +
I am calling a service that return JSON data. Script: $.ajax({ type: "POST", url:
I want to catch a specific failure of this JavaScript code: var script =
<?php $numPosts = 5; $feedURL = http://#######.tumblr.com/api/read/?num=$numPosts; $xml = @simplexml_load_file($feedURL); foreach(@$xml->posts->post as $post){ $posts
I was wondering if anyone here had some experience writing this type of script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.