Php 试图通过ajax删除表行,代码点火器,但它';它不工作了

Php 试图通过ajax删除表行,代码点火器,但它';它不工作了,php,jquery,mysql,ajax,codeigniter,Php,Jquery,Mysql,Ajax,Codeigniter,我试图删除产品添加到购物车单独,也整个购物车时,点击。如果用户是否登录,我有两个场景。在这两种情况下,当我删除单行时,它会被删除,但当我重新加载页面时,该行会再次出现数据完全从数据库中删除,但在前端它不工作,但在删除整个购物车的情况下,它工作正常。jQuery或PHP中的问题在哪里。我的购物车的视图为: 以下是Jquery中删除函数的代码 $(document).on('click' , '.delBtn' , function(){ var rowId = $(this).a

我试图删除产品添加到购物车单独,也整个购物车时,点击。如果用户是否登录,我有两个场景。在这两种情况下,当我删除单行时,它会被删除,但当我重新加载页面时,该行会再次出现数据完全从数据库中删除,但在前端它不工作,但在删除整个购物车的情况下,它工作正常。jQueryPHP中的问题在哪里。我的购物车的视图为:

以下是Jquery中删除函数的代码

    $(document).on('click' , '.delBtn' , function(){
    var rowId = $(this).attr('rel');
    alert(rowId)
    var thisElement = $(this);
    swal({
      title: "Are you sure?",
      text: "You want to delete the domain from your cart!",
      type: "warning",
      showCancelButton: true,
      confirmButtonClass: "btn-danger",
      confirmButtonText: "Yes, delete it!",
      cancelButtonClass: "btn-warning",
      cancelButtonText: "No, cancel plx!",
      closeOnConfirm: false
    },
    function(isConfirm) {
      if(isConfirm) {
            alert("yes");
            $.ajax({
                type    : 'POST',
                url     : base_url+'home/remove',
                data    : {id:rowId},
                beforeSend : function(){

                },
                success : function(data){
                    alert(data)
                    if(data == 'true'){
                        swal({
                            type : 'success',
                            title : "Done!",
                            text    : "Domain Deleted From your Cart!",
                            timer: 2000,
                            showConfirmButton: false
                        });
                        var total_item = $('.total_items').html();
                        $('.total_items').html(parseInt(total_item)-1);
                        thisElement.closest('tr').remove();
                        var sum_value = update();
                        if(sum_value == 0) {
                            $('.view_cart_table').remove();
                            $('h2.empty').html('Your Cart is empty.');  
                        }else{
                            $('.total_amount span').html(sum_value);
                        }

                    }
                    if(data == 'all'){
                        swal({
                            type : 'success',
                            title : "Done!",
                            text    : "Your Cart is Empty Now!",
                            timer: 2000,
                            showConfirmButton: false
                        });
                        var total_item = $('.total_items').html();
                        $('.total_items').html(total_item-total_item);
                        $('.view_cart_table').remove();
                        $('h2.empty').html('Your Cart is empty.');
                    }
                }
            });
        }
    });
});
在数据中,它返回数据值,但当我重新加载页面时,它再次出现

下面是Php代码点火器的代码

    public function remove(){ /* This Function is for Removing domains From cart Whole and individually */
        $rowid = $this->input->post('id');
        if($this->session->userdata('users_Data')){
            $user_id = $this->session->userdata['users_Data']['user_id'];
        }else{
            $user_id = '';
        }
        if($rowid === ''.$user_id.'all'){
            $this->main_model->del_all_cart($user_id);
            $this->cart->destroy();
            echo "all";
        }else if($rowid === 'all'){
            $this->cart->destroy();
            echo "all";
        }else{
            if($user_id == ''){
                $data = array(
                'id' => $rowid,
                'qty' => 0
                );
                $this->cart->update($data);
                echo "true";
            }else{
                $this->main_model->del_single_cart($rowid);
                $data = array(
                'id' => $rowid,
                'qty' => 0
                );
                $this->cart->update($data);
                echo "true";
            }
        }

    }

有人能帮忙吗?

使用这个$this->cart->remove($rowid);//对于删除单行deleteIt’s done,我使用了这个'id'=>$row id,id保存在数据库中,但是对于删除或更新,我们必须使用row id,这是购物车类默认提供的id,这就是它不工作的原因。remove();应该这样做。您已经抓取了要删除的tr。