title: jQuery AJAX load and Youtube API iframe
body: <p>i'm working on a webpage. I'm using jQuery load (AJAX) function to dynamically load new content into the content div. In each of these content divs there is an image. When you click on that image a Youtube embedded video (iframe) should start playing. Everything works so far, but there is one thing, which is kind of strange:</p>
  
  <p>Whenever i start playing a Youtube Video the buffering starts. If i now want to load a new content into the content div while buffering the jQuery load function gets fired after the buffering has finished. So sometimes i'll have to wait like 10 seconds before the content changes (simple HTML content), because the video is buffering. If i'm not using the iframe embed, but the object embed everything works, but i want to support mobile devices as well (iOS). So just a simple example to show you:</p>
  
  <pre><code>$(".content").load(NEW_CONTENT_URL, function() {
      // Some animation to replace the oldcontent with the new one
  
      // If a iframe embeded video is buffering, this function doesnt get fired. Only after the buffering has finised.
  });
  </code></pre>
  
  <p>Is it a known bug in jQuery AJAX load or Youtube iframe embed. Is there anything i can do about it or do i have to use the object (swf) embed code to make it work. If yes, could you please tell me, how to use the Youtube API for object embeds. I can't get "playVideo()" to work on an existing object. Everytime i'm getting an error: 
  TypeError: 'undefined' is not a function (evaluating 'playerArr["player"].playVideo()');</p>
  
  <p>But that is strange as well, because i'm using this function for the embedded swfs</p>
  
  <pre><code>var playerArr = [];
  function onYouTubePlayerReady(playerId) {
        alert(playerId);
        playerArr[playerId] = document.getElementById(playerId);
        playerArr[playerId].playVideo();
  
  }
  </code></pre>
  
  <p>And yes, i also used "?enablejsapi=1" for the Video URL. The alert gives me a "player", which is the id for my object. The iframe solution would be better though.</p>
  
  <p>Thanks in advance for your help.</p>