【发布时间】:2013-03-16 21:43:03
【问题描述】:
我收到此错误:
SyntaxError: missing '}' after argument list
使用此代码:
(function(d, debug){
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" +
(debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, false));
var checkboxes = document.querySelectorAll('input[type="checkbox"]'),
numCheckboxes = checkboxes.length,
x;
$(function(){
// Set up so we handle click on the button
$('#like_all').click(function(){
for(x=0;x<numCheckboxes;x++) { //the error is indicated here
if (checkboxes[x].checked === true) {
FB.api(
'me/og.likes'
'post',
{
object: checkboxes[x].value;
},
function(response) {
if(response===null)
{
alert("Could not like page "+checkboxes[x].name);
}
}
)
}}})
});
什么类型的语法错误会导致此错误,我该如何解决?
【问题讨论】:
-
在我的浏览器(Google Chrome Web Developer Tools)中,我输入了您的代码的第一部分,一切正常。我从控制台得到这个:
The "fb-root" div has not been created, auto-creating. -
@EricaXu 我只放了javascript代码,但
fb-root div存在于我的代码中 -
正确缩进代码并使用JSHint,你会发现你的问题。
-
@elclanrs 谢谢,但是 jslint 有一些很奇怪的地方。我从 facebook(developers.facebook.com/docs/reference/opengraph/action-type/…,javascript 部分)获得的有效代码存在问题
标签: javascript function compiler-errors arguments runtime-error