title: Get Youtube comments with jQuery
body: <p>I have a project for a client that will be using a YouTube comment stream as a type of "chat." I am making an authenticated call to YouTube using the GData APIs with the Zend Framework. I am looking for a way to run the script that will pull the comment stream with a refresh button so that the users don't have to refresh the page to see their comment, or any new comments that appear. I believe this can be accomplished with JQuery, but after a bt of searching I haven't really found a good explanation as to how. Here are a few brief snippits of my code to give you some idea of what I am looking at:</p>
  
  <pre><code>$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
  $_SESSION['yt'] = serialize($yt);
  
  /***************** Adds a comment if applicable *****************/
  
  if(isset($_POST['btn_submit']))
  {
  $videoEntry = $yt-&gt;getVideoEntry('QQoFLrZ5C3M');
  
  $newComment = $yt-&gt;newCommentEntry();
  $newComment-&gt;content = $yt-&gt;newContent()-&gt;setText($_POST['comment']);
  
  // post the comment to the comments feed URL for the video
  $commentFeedPostUrl = $videoEntry-&gt;getVideoCommentFeedUrl();
  $updatedVideoEntry = $yt-&gt;insertEntry($newComment, $commentFeedPostUrl,
  'Zend_Gdata_YouTube_CommentEntry');
  }
  
                          /****************************************************************/
  
  
  &lt;div id="coments"&gt;
  
  $commentFeed = $yt-&gt;getVideoCommentFeed('QQoFLrZ5C3M');
  
  echo '&lt;div id="refresh"&gt;&lt;a href="#" style="margin-right: 15px; border: 0;"&gt;&lt;img src="../common/img/refresh.png" alt="refresh" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;';
  
  foreach ($commentFeed as $commentEntry) {
  echo '&lt;div class="comment"&gt;';
  echo  '&lt;a href="http://youtube.com/user/' . utf8_decode(utf8_encode($commentEntry-&gt;author[0]-&gt;name-&gt;text)) . '" target="_blank" class="youtube_user"&gt;' . utf8_decode(utf8_encode($commentEntry-&gt;author[0]-&gt;name-&gt;text)) . '&lt;/a&gt;&lt;br /&gt;';
  
  echo  '&lt;span style="font-size: 14px;"&gt;' . utf8_decode(utf8_encode($commentEntry-&gt;content-&gt;text)) . '&lt;/span&gt;&lt;br /&gt;';
  
  // Format time
  $timeAgoObject = new convertToAgo;
  $ts = strtotime($commentEntry-&gt;updated-&gt;text);
  $timestamp = ($timeAgoObject -&gt; makeAgo($ts)); // Then convert to ago time
  
  echo  '&lt;div class="yt_timestamp"&gt;' . $timestamp  . '&lt;/div&gt;';
  echo '&lt;/div&gt;';
  }
  ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Note that the youtube class is not always new (hence the serialization into a session variable) I just stripped out the if statement for easy reading.</p>