有誰能告訴我爲什麼回調不能用於下面給出的類似按鈕的代碼?就我所見,該代碼是JavaScript中設置的標準。第一個按鈕被初始化,然後API被異步加載,並提供回調函數。FaceBook像按鈕回調不起作用
<div id="fb-root"></div>
<script>
window.fbAsyncInit=function(){
FB.init({
appId:'',//App ID
status:false,// check login status
cookie:true,// enable cookies to allow the server to access the session
xfbml:true// parse XFBML
});
// Additional initialization code here
FB.Event.subscribe('edge.create', function(response) {
//alert("user_id1:<?php echo $user_id1; ?>, user_id2:<?php echo $user_id2; ?>");
/*var data={
action:"ap_buttons_give_points",
author_id:<?php echo $author_id; ?>,
post_id:<?php echo $post_id; ?>,
type:"like"
}
jQuery.post("<?php echo $ajax_url; ?>",data,function(resp){
});*/
alert('You just liked the page!');
});
FB.Event.subscribe('edge.remove', function(response) {
/*var data={
action:"ap_buttons_take_points",
author_id:<?php echo $author_id; ?>,
post_id:<?php echo $post_id; ?>,
type:"like"
}
jQuery.post("<?php echo $ajax_url; ?>",data,function(resp){
//alert("fb remove:"+resp);
});*/
alert('You just unliked the page!');
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
該按鈕是HTML5。代碼是:
。在這種情況下如何定義回調? – 2012-07-10 18:04:05我也得到這個:FB.init已經被調用 - 這可能表明一個問題 – 2012-07-10 18:10:21