我正在尝试访问Facebook上公共活动的人数。我已经阅读了如何初始化FB.api的文档,但是当我尝试运行代码时,我得到了 -
第29行的“Uncaught SyntaxError:Unexpected identifier”(var going)
$(document).ready(function(){
$('#dataButton').click(getFacebookData);
$("input").keypress(function(event) {
if (event.which == 13) {
event.preventDefault();
getFacebookData();
}
});
$.getScript('//connect.facebook.net/en_UK/all.js', function(){
FB.init({
appId: 'XXXXXXXXXX',
});
$('#loginbutton,#feedbutton').removeAttr('disabled');
FB.getLoginStatus(updateStatusCallback);
});
});
//variables --> array goes here
function getFacebookData() {
//variables
var url = $('#url').val();
var going = FB.api('/'url'/attending', function(response){console.log(response)});
$('#text').append(going);
};
有谁知道我做错了什么? 提前谢谢
答案 0 :(得分:0)
改变 -
var going = FB.api('/'url'/attending', function(response){console.log(response)});
到 -
var going = FB.api('/'+url+'/attending', function(response){console.log(response)});
(注意 + 符号,以连接字符串和变量)