2012-11-21 1 views
0

않습니다, 모든 괜찮 :여러 FB.Event.subscribe가 발생하지 않지만 하나의 나는 내가 다음을 사용하는 경우 페이지</p> <p>에 <code>comment.create</code> 및 <code>comment.remove</code>를 추가하려고

window.fbAsyncInit = function(){ 
    FB.Event.subscribe('comment.create', function(response){ 
    $.ajax({ 
    type: "POST", // form method 
    url: "/pages/includes/add_fb_comments.php",// destination 
    data: "url=" + encodeURIComponent(response.href) + "&id=<?=$id?>&action=add", 
    cache: false, 
    success: function(){ 
    alert('Success' + encodeURIComponent(response.href) + response.commentID); 
    } 
    }); 
    }); 
    }; 

하지만, 그러나 내가 다음, 아무것도 화재를 추가 할 때마다, 아약스는 발생하지 않으며 내가 '같은 window.fbAsyncInit = function(){ 내 모두를 시도했습니다

FB.Event.subscribe('comment.remove', function(response){ 
    $.ajax({ 
    type: "POST", // form method 
    url: "/pages/includes/add_fb_comments.php",// destination 
    data: "commentID=" + response.commentID + "&action=remove", 
    cache: false, 
    success: function(){ 
    alert('removed comment: ' response.commentID); 
    } 
    }); 
}); 

때문에 더 성공 메시지하지 않습니다 ve는 분리되어 시도했다 window.fbAsyncInit = function(){ 나는 완전한 별도의 시도를했다 심지어 <script></script> 그러나 그들은 단지 발사하지 않는다.

이 문제는 알려진 문제입니까? 나는 그들이 항상 함께 존재한다고 확신 할 수 없다.

어떤 아이디어라도?

이 내가 노력하고있어 전체 실제 코드 :

<div class="fb-comments" data-href="<? echo curPageURL(); ?>" data-num-posts="4" data-width="578" mobile="false"></div> 
     <script> 
      window.fbAsyncInit = function(){ 
        FB.Event.subscribe('comment.create', function(response){ 
         $.ajax({ 
          type: "POST", // form method 
          url: "/pages/includes/add_fb_comments.php",// destination 
          data: "url=" + encodeURIComponent(response.href) + "&id=<?=$id?>&action=add", 
          cache: false, 
          success: function(){ 
          alert('Success' + encodeURIComponent(response.href) + response.commentID); 
          } 
         }); 
        }); 
      }; 

      window.fbAsyncInit = function(){ 
        FB.Event.subscribe('comment.remove', function(response){ 
         $.ajax({ 
          type: "POST", // form method 
          url: "/pages/includes/add_fb_comments.php",// destination 
          data: "commentID=" + response.commentID + "&action=remove", 
          cache: false, 
          success: function(){ 
          alert('removed comment: ' response.commentID); 
          } 
         }); 
        }); 
      }; 
      </script> 

답변

0

window.fbAsyncInit이 같은 속성을 설정하고, 이러한 순차적으로 실행하고, 누적되지 않습니다대로, 마지막 기능이 실제로 설정되어 있습니다.

이제 제 3의 fbAsyncInit =... 블록이 있고 SDK가 초기화되고 위와 같은 이유로 절대 실행되지 않습니다.

이 모든 것을 하나의 fbAsyncInit으로 옮기면 좋을 것입니다.

관련 문제