在同一行编辑输入字段时,你能帮我介绍如何传递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>
答案 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
}
});