我收到此错误:的JavaScript:语法错误:之后的参数列表中缺少“}”
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)中,我输入了代码的第一部分,一切都正常。我从控制台得到了这个:“'fb-root”div尚未创建,自动创建''。 – 2013-03-16 21:46:15
@EricaXu我只放了javascript代码,但'fb-root div'存在于我的代码中 – 2013-03-16 21:48:02
正确缩进代码并使用[JSHint](http://www.jshint.com/),你会发现你的问题。 – elclanrs 2013-03-16 21:56:07