2010-11-23 2 views
0

YouTube의 일부 비디오를 당겨 사이트의 멀티미디어 페이지에 표시하고 있습니다. 코드는 잠시 동안 정상적으로 작동하지만 이제는 신비하게도 깨졌습니다. 내 가정용 컴퓨터에서 테스트하면 모든 것이 잘 작동한다는 것을 알 수 있습니다. 왜 이런 일이 일어날 지 아십니까? (참고 : 워드 프레스 사이트, JS는 WP 포스트에서 외부 코드는 github @ 표시, 브라우저 도구 나 JS 온라인 보풀 사용하여 눈에 띄는 오류 없음) 사전에JS는 가정용 컴퓨터에서 완벽하게 작동하지만 서버에서는 그렇지 않습니다.

감사합니다 ...

자바 스크립트 :

$(document).ready(function() { 
    //some variables 
    var videos = [];      //placeholder for video information returned from youtube 
    var video_elm_arr = $('.video');  //array of 'video' elements in DOM  
    //hide videos until ready 
    $('.video').addClass('hidden');  
    //pull video data from youtube 
    $.ajax({ 
    url: 'http://gdata.youtube.com/feeds/api/users/danwoodson/uploads?alt=json', 
    dataType: 'jsonp', 
    success: function(data) { 
     alert(data); 
     $.each(data.feed.entry, function(i,item){ 
     //only take the first 7 videos 
     if(i > 6) 
      return;    
     //create object to hold the video's info 
     videos[i] = {}; 
     videos[i].title = item.title.$t; 
     videos[i].url = item.media$group.media$content[0].url;   //this will need to be cleaned before use 
     videos[i].summary = item.content.$t; 
     videos[i].thumbnail = item.media$group.media$thumbnail[3].url;    
     //assign title 
     $(video_elm_arr[i]).find('.video_title').append(videos[i].title);    
     //clean url 
     var video_url = videos[i].url; 
     var index = video_url.indexOf("?"); 
      if (index > 0) 
      video_url = video_url.substring(0, index); 
     //and re-assign 
     videos[i].url = video_url;       
     if(i == 0){ //only for featured/main 
      //insert flash object in video element 
      $(video_elm_arr[i]).find('.video_title').after('<object id="video_0" width="475" height="267.1875">' + 
            '<param name="movie" value="' + video_url + '&showinfo=0"></param>' + 
            '<param name="allowFullScreen" value="true"></param>' + 
            '<param name="allowscriptaccess" value="always"></param>' + 
            '<embed src="' + video_url + '&showinfo=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="475" height="267.1875"></embed>' + 
            '</object>'); 
      //and include summary 
      $(video_elm_arr[i]).find('#featured_summary').html(videos[i].summary); 
     } 
     else{ //else just use thumbnail and enlarge 
      $(video_elm_arr[i]).find('.video_title').after('<img src="' + videos[i].thumbnail +'" alt="video" id="video_' + i + '" />'); 
      $(video_elm_arr[i]).find('img').animate({height: 84.375, width: 150}, 500);    
     }      
     //and finally show 
     $(video_elm_arr[i]).removeClass('hidden'); 
     }); 
    }, 
    error: function(XMLHttpRequest, textStatus, errorThrown) {alert("error with retrieving videos");} 
    });  
    //create functionality 
    $('.non_featured').bind('click', function(){ 
    //get clicked video's id 
    var clicked_vid_id = $(this).find('img').attr('id'); 
    //clean 
    var index = clicked_vid_id.indexOf("_"); 
    if (index > 0) 
     clicked_vid_id = clicked_vid_id.substring(index+1);   
    //get featured video's id 
    var cur_featured_vid_id = $('#featured').find('object').attr('id'); 
    //clean 
    var index = cur_featured_vid_id.indexOf("_"); 
    if (index > 0) 
     cur_featured_vid_id = cur_featured_vid_id.substring(index+1);   
    //create new swf object with clicked video's information 
    var new_featured_vid_swf = '<object id="video_' + clicked_vid_id + '" width="475" height="267.1875">' + 
           '<param name="movie" value="' + videos[clicked_vid_id].url + '?showinfo=0&autoplay=1"></param>' + 
           '<param name="allowFullScreen" value="true"></param>' + 
           '<param name="allowscriptaccess" value="always"></param>' + 
           '<embed src="' + videos[clicked_vid_id].url + '?showinfo=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="475" height="267.1875"></embed>' + 
           '</object>';   
    //clear out clicked video's image 
    $(this).find('img').remove();    
    //clear out featured video's original swf object 
    $('#featured').find('object').remove();     
    /*assign newly created swf objects to their appropriate locations*/ 
    //set clicked 
    $(this).find('.video_title').html(videos[cur_featured_vid_id].title); 
    $(this).append('<img src="' + videos[cur_featured_vid_id].thumbnail +'" alt="video" id="video_' + cur_featured_vid_id + '" />'); 
    $(this).find('img').animate({height: 84.375, width: 150}, 500); 
    //and set new featured/main 
    $('#featured').find('.video_title').html(videos[clicked_vid_id].title); 
    $('#featured').find('.video_title').after(new_featured_vid_swf); 
    $('#featured').find('#featured_summary').html(videos[clicked_vid_id].summary);   
    }); 
}); 
+0

YouTube 동영상을 가져 오기 위해 사용하는 코드는 무엇입니까? –

+3

"고장났다"는 것은 무엇을 의미합니까? 관련 코드, 브라우저 오류, HTTP 요청 로그 등을 최소한 게시하십시오. 소스 코드에 대한 링크가 더 이상의 컨텍스트 없이는 도움이되지 않습니다. –

+0

크롬 개발자 도구를 사용하여 오류를 확인하면 매우 유용합니다. 가능한 실패에 대해 XHR 및 JavaScript를 모니터링하십시오. –

답변

0

귀하의 페이지에서 발생하는 오류입니다. Internet Explorer, Chrome 및 Firefox에는 모두이 정보를 표시하는 데 사용할 수있는 우수한 디버거/자바 스크립트 콘솔이 있습니다.

'pollsL10n' is undefined polls-js.js?ver=2.50, line 1 character 62 
pollsL10n.show_loading=parseInt(pollsL10n.show_loading) 


Object doesn't support this property or method headcount-multimedia, line 135 character 9 
$(".tweet").tweet({ 


Object doesn't support this property or method slider.js, line 32 character 4 
jQuery("#main-photo-slider").codaSlider(); 

Object doesn't support this property or method main.js, line 31 character 1 
jQuery.cookie('widget widget_text'); 
+0

오른쪽. 페이지가 작동을 멈추기 전에 이러한 오류가 있었고, 내가 일한 것은 아무것도 없습니다 (저는 인턴입니다). 나는 여전히 jQuery가 셀렉터를 찾는 데 문제가되는 것처럼 느껴진다. (이상한 일이다 ...) – danwoods

+0

jQuery가 셀렉터를 찾지 못하는 이유를 알아 냈다. 이제 찾았지만 아직 내용을 추가하지 않았습니다 – danwoods

+0

위와 같은 오류는 해당 스크립트의 해당 시점 이후에 오는 모든 것을 방해 할 수 있습니다. 스크립트는 발생했을 때 실행을 중지합니다.보고있는 문제와 관련이 있거나 없을 수도 있습니다. –

관련 문제