-1

嗨,我的代码的第 137 行出现“未捕获的 SyntaxError:意外令牌}”错误

function removeItem(sender, itemCode){
    $.ajax({
        url: 'cart_update.php?removep=' + itemCode,
        success: function(){
            var parent = $(sender).parent();
            parent.remove();
            });
        } ////137
}

一些帮助?

4

3 回答 3

1

您缺少);标有////137

而你已经不需要);在线上面了////137

正确的代码

function removeItem(sender, itemCode){
    $.ajax({
        url: 'cart_update.php?removep=' + itemCode,
        success: function(){
            var parent = $(sender).parent();
            parent.remove();
        }
    }); ////137
}
于 2013-10-16T15:05:33.303 回答
1

记得关闭 $.ajax 前导括号:

      }); ////137
}

只需添加一个“);” 在第 137 行

于 2013-10-16T15:05:45.373 回答
1

将其更改为:

function removeItem(sender, itemCode){
    $.ajax({
        url: 'cart_update.php?removep=' + itemCode,
        success: function(){
            var parent = $(sender).parent();
            parent.remove();
            });
        });
}

你错过了 $.ajax(); 的关闭。

于 2013-10-16T15:06:33.790 回答