丢失的 ; before 语句: $(this).closest('tr').find('.tableRow'){\n

发布于 2024-10-02 01:23:39 字数 1586 浏览 1 评论 0原文

$('.removeItem').live('click',function(){                                       
                        var postData = {};
                        $(this).closest('tr').find('.tableRow'){
                            var keyPrefix = 'data[' + index + ']';
                            postData[keyPrefix + '[index]'] = $(this).closest('tr').find('.row_id').text();
                            postData['data['+ index +'][order_id]'] = $('#order_id').text();
                        };

我不确定我想做的事情是否显而易见,但有人能发现我哪里出错了吗?

编辑:

完全是我的错,在我原来的帖子中有点误导,这是我的完整代码:

$('.removeItem').live('click',function(){                                       
                    var postData = {};
                    $(this).closest('tr').find('.tableRow'){
                        var keyPrefix = 'data[' + index + ']';
                        postData[keyPrefix + '[index]'] = $(this).closest('tr').find('.row_id').text();
                        postData['data['+ index +'][order_id]'] = $('#order_id').text();
                    )};

                $.ajax
                    ({
                    type: "POST",
                    url: "deleterow.php",
                    dataType: "json",
                    data: postData,
                    cache: false,
                    success: function()
                        {
                            alert("Item Deleted");
                        }
                    });         
                $(this).closest('tr').remove();
                calcTotal();
            }); 
$('.removeItem').live('click',function(){                                       
                        var postData = {};
                        $(this).closest('tr').find('.tableRow'){
                            var keyPrefix = 'data[' + index + ']';
                            postData[keyPrefix + '[index]'] = $(this).closest('tr').find('.row_id').text();
                            postData['data['+ index +'][order_id]'] = $('#order_id').text();
                        };

I'm not sure if its obvious what i'm trying to do but can anyone spot where i'm going wrong?

EDIT:

Completely my fault, was slightly misleading in my original post, this is my complete code:

$('.removeItem').live('click',function(){                                       
                    var postData = {};
                    $(this).closest('tr').find('.tableRow'){
                        var keyPrefix = 'data[' + index + ']';
                        postData[keyPrefix + '[index]'] = $(this).closest('tr').find('.row_id').text();
                        postData['data['+ index +'][order_id]'] = $('#order_id').text();
                    )};

                $.ajax
                    ({
                    type: "POST",
                    url: "deleterow.php",
                    dataType: "json",
                    data: postData,
                    cache: false,
                    success: function()
                        {
                            alert("Item Deleted");
                        }
                    });         
                $(this).closest('tr').remove();
                calcTotal();
            }); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

热情消退 2024-10-09 01:23:39

这里的这一行:

                $(this).closest('tr').find('.tableRow'){

缺少一些东西。什么?不清楚,但也许应该是

                $(this).closest('tr').find('.tableRow').each(function() {

This line here:

                $(this).closest('tr').find('.tableRow'){

is missing something. What? Not clear, but maybe it should be

                $(this).closest('tr').find('.tableRow').each(function() {
埖埖迣鎅 2024-10-09 01:23:39

您忘记了 .live 调用中的结束 )

忽略回调的内容,您的代码是

$('.removeItem').live('click',function(){ ... } ;
                                               ^

注意您正在调用一个带有两个参数的函数,但没有关闭括号。

You forgot the closing ) in the .live call.

Ignoring the contents of the callback, your code is

$('.removeItem').live('click',function(){ ... } ;
                                               ^

Notice that you're calling a function with two parameters, but not closing the parentheses.

☆獨立☆ 2024-10-09 01:23:39

从“index”变量来看,我认为代码应该是:

$('.removeItem').live('click', function() {
  var postData = {};
  $(this).closest('tr').find('.tableRow').each(function(index) {
    var keyPrefix = 'data[' + index + ']';
    postData[keyPrefix + '[index]'] = $(this).closest('tr').find('.row_id').text();
    postData['data[' + index + '][order_id]'] = $('#order_id').text();
  });
});

Judging by the "index" variable, I think that the code should be:

$('.removeItem').live('click', function() {
  var postData = {};
  $(this).closest('tr').find('.tableRow').each(function(index) {
    var keyPrefix = 'data[' + index + ']';
    postData[keyPrefix + '[index]'] = $(this).closest('tr').find('.row_id').text();
    postData['data[' + index + '][order_id]'] = $('#order_id').text();
  });
});
淡笑忘祈一世凡恋 2024-10-09 01:23:39

您没有关闭“实时”功能块。您需要将 }); 添加到最后一行的末尾。

You don't close the "live" function block. you need to add }); to the end of last line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文