开发者

Output Youtube video

I need to output youtube video via Ajax in my rails 3 App. There are other ways of doing it, but for js.erb, i need to do it in a different way.I want to display youtube video using jquery's html() method or some other method. I tried this:

$("#bt").click(function () {

      $("#vid").html("
   <object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/9QS0q3mGPGg?fs=1&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param>"+"<param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/9QS0q3mGPGg?fs=1&amp;hl=en_US&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width开发者_JAVA技巧="640" height="390"></embed></object>");
    });

But it is not displaying the video.Is there a way to do it?


You have an error with your syntax. You open and close your text with a ", but your text also contains ", changing it to ' should make this work:

$('#bt').click(function () {
      $('#vid').html('<object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/9QS0q3mGPGg?fs=1&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param>"+"<param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/9QS0q3mGPGg?fs=1&amp;hl=en_US&amp;rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="390"></embed></object>');
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜