我收到此錯誤:的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