Jquery success

Jquery success

Dear All

I am using following script to load a video from YouTube.com 


  1. $('.samplevideolist').click(function(){
  2. $('#samplevideodiv').slideDown(1000);
  3.     // $('#foo').show();
  4. var id=this.id;  
  5. var arr=id.split('samplevideos');
  6. var videoid=arr[1];
  7.  
  8. $('#videoid').val(videoid);   
  9.    
  10.          $.getJSON("sampleyoutubevideojsonfill.php", {id: $('#videoid').val()}, function(data){
  11.             $('#samplevideonamediv').text(data['name']);
  12.  
  13. $('#samplevideo').html(data['code']);
  14.         }).done(alert('ttt') );    // Displays alert ttt
  15.     });
  16.            
  17.     }).fail(function(){
  18.             alert("OUCH!")
  19.       });
  20.   
  21.  
  22.  
  23.  })(jQuery);
So as to auto play this video

I found following script


for auto play of youtube video

However I tried to apply  it as per code mentioned above
the code displays alert message  Displays alert ttt

However I tried


  1. function samplevideodivblank() {
  2.  $('#samplevideo').html('');
  3. }
  4.  $('#foo').click(function(){
  5.  $('#samplevideodiv').slideUp(1000);
  6.  $('#foo').hide();
  7.    });  
  8.  $('.samplevideolist').click(function(){
  9. $('#samplevideodiv').slideDown(1000);
  10.     // $('#foo').show();
  11. var id=this.id;  //alert(id);
  12. var arr=id.split('samplevideos');
  13. var videoid=arr[1];
  14.  
  15. $('#videoid').val(videoid);   
  16.    
  17.          $.getJSON("sampleyoutubevideojsonfill.php", {id: $('#videoid').val()}, function(data){
  18.             $('#samplevideonamediv').text(data['name']);
  19.  
  20. $('#samplevideo').html(data['code']);
  21.         }).done(setTimeout(autoPlayVideo(), 50000));    // code changed
  22.     });
  23.            
  24.     }).fail(function(){
  25.             alert("OUCH!")
  26.       });
  27.   
  28.  
  29.  
  30.  })(jQuery);
But the code doesnot works

Please help