2011-10-31 2 views
0

아약스의로드 페이지 내에서 페이스 북 스크립트를 수입 ...액세스 내가 AJAX를 기반으로 페이스 북의 로그인 시스템을하고있어, 나는 그와 약간의 문제가있어

을 내가 페이스 북 로그인과 양식 페이지가 버튼을 처음 클릭 할 때 AJAX를 통해 호출되는 버튼. 누군가가 버튼을 클릭 할 때마다 호출되며, 로그인이 성공하면 콘텐츠를 변경하고, sucessfull이 아닌 경우 동일한 양식을 표시합니다.

<form method="post" id="regist_form" enctype="application/x-www-form-urlencoded" action="asd.php"> 
<table> 
<tr> 
    <?php echo $this->form->username; ?> 
</tr> 
<tr> 
    <?php echo $this->form->password; ?> 
</tr> 
<tr> 
<td><br/><script type="text/javascript"> 
    document.write('<div class="fb-login-button" id="face_login" onlogin="loginAsFacebook()" scope="email,user_activities,publish_stream">Facebook</div>'); 
</script> 
</td> 
<td><br/> 
    <?php echo $this->form->login_form_csrf.$this->form->login_user; ?> 
</td> 
</tr> 
</table> 
</form> 

문제는 내가 AJAX를 통해이 양식 페이지를 호출 할 때, 페이지가 어떻게 든 갱신 중간에 중단되는 것입니다. 이 PHP를 통해로드 될 때, 그것은

내가 몇 가지 시도 후

... 페이스 북의 로그인 버튼없이 너무 OK 작동, 나는이 문제를 찾을 것을 시도 ... OK로드 내가 '때문에

이 수 ...

$(document).ready(function(){ 
    $('#face_gen').append('<div class="fb-login-button" class="face_login" onlogin="loginAsFacebook()" scope="email,user_activities,publish_stream">Facebook</div>'); 
    FB.XFBML.parse(document.getElementById('face_login')); 
}); 

지금은 AJAX를 통해하지만 페이스 북의 버튼의 렌더링없이 확인로드 : document.write를 관련 ... 나는 그것을 변경 봤어. acebook의 모든 스크립트가 상위 페이지에로드 되었습니까?

<script src="//connect.facebook.net/en_US/all.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    FB.init({ 
     appId  : 'xxxxxxxxxxxxxxx', // App ID 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     oauth  : true, // enable OAuth 2.0 
     xfbml  : true, // parse XFBML 
     fbml5  : true 
    }); 
</script> 

나는이를 사용하여 시도했지만 역시 작동하지 않았다 :

$("#user_reg_login").load("logincontent/logincontent/",function(){ 
    FB.XFBML.parse(document.getElementById('face_login')); 
}); 

를 내가 제대로 버튼을 렌더링하기 위해 지금 실종 무엇?

답변

1

좋아, 내가 어떻게 작동하는지 알아.

<form method="post" id="regist_form" enctype="application/x-www-form-urlencoded" action=""> 
<table> 
    <tr> 
     <?php echo $this->form->username; ?> 
    </tr> 
    <tr> 
     <?php echo $this->form->password; ?> 
    </tr> 
    <tr> 
     <td id="face_gen"><br/><script type="text/javascript"> 
      $(document).ready(function(){ 
       $('#face_gen').append('<div class="fb-login-button" class="face_login" onlogin="loginAsFacebook()" scope="email,user_activities,publish_stream">Facebook</div>'); 
       FB.XFBML.parse(document.getElementById('face_login')); 
      }); 
     </script> 

     </td> 
     <td><br/> 
      <?php echo $this->form->login_form_csrf.$this->form->login_user; ?> 
     </td> 
    </tr> 
</table> 
</form> 

내가 젠드 프레임 워크를 사용하고 있다는 말을 잊었 :

는 여기에 솔루션입니다.

이제 AJAX call = D 후에 버튼이 잘 렌더링됩니다.

관련 문제