datatable - laravel:将id变量从视图传递给控制器

时间:2017-12-30 11:37:12

标签: php jquery laravel datatable

在同一行编辑输入字段时,你能帮我介绍如何传递id的值吗? 使问题更简单: 我有三列的表:

1- id

2-描述

3- vendor_id(这是输入字段中的视图)

当我编辑供应商ID时,我想使用ajax将值id和vendor_id传递给控制器 希望有明确的帮助

       <script type="text/javascript">
       var oTable = $('#users-table').DataTable({
            dom: 'flBrtip',
               processing: true,
            serverSide: true,
            ajax: {
                 url: 'custom-filter-data',
         columns : [
         {data: 'id'},  
          {data: 'description', name: 'description'},
         {data: 'vendor_id',render: function (data) {        
           return ('<label hidden>'+data+'</label> <input type="text" id="vendor" class="vendor" onClick="this.select();" value="'+data+'">');   
           }}, 
             ],
         pageLength: 10,
        };
    oTable.draw();
   </script>

1 个答案:

答案 0 :(得分:0)

  var id = "fill you variable";
  var vendor_id = "fill you variable";
  var description = "fill you variable";

  $.ajax({
      url: 'custom-filter-data',
      type: 'POST',
      data: {'id':id, 'vendor_id':vendor_id,
     'description': description,'_token':'{{ csrf_token() }}'},
      success: function (data) {
             //code after ajax success 
      }
  });