include json value in embed tag

Go To StackoverFlow.com

0

I am unable to set json value to scr attribute of embed tag from javascript file.

$.getJSON("url",function(data){

 jsonMovies = data.Movies;
 $.each(data.Movies, function(index,value){
     numofMovs[i]= index;
     if (numofMovs[i] == 'Movie6')
     {
        var parent = $('embed#video1').parent();            
        $('embed#video1').remove();             
        parent.append('<embed type="video/mp4" width="200px" height="200px" id = "video1"           
        src=value.Video />');   
     }
}

} Please let me know the correct syntax for including the json value in src attribute (src=value.Video).

Thanks, Surabhi

2012-04-04 03:49
by Surabhi


0

You need to concatenate the value into the string:

parent.append('<embed type="video/mp4"
      width="200px"
      height="200px"
      id="video1"
      src=' + value.Video + '/>');
          ^^^^^^^^^^^^^^^^^^^

There's a considerable difference between:

x = 'hello';
alert(x);   // shows hello
alert('x'); // shows x
2012-04-04 03:54
by Marc B
I tried to concatenate the value but still the video is not playing. parent.append('') - Surabhi 2012-04-04 04:04
have you checked that value.Video actually contains a valid URL - Marc B 2012-04-04 04:05
yes it contains the URL. I confirmed it with an alert statement - Surabhi 2012-04-04 04:10
Thanks Marc. After installing the QuickTime plug-in above code worked fin - Surabhi 2012-04-04 09:59
Ads