Php 如何通过ajax将选中的行数据传递到另一个数据表中?
我试图获取选中的行数据,但我不知道如何从提交函数传递它。因此,我可以将数据传递给另一个Php 如何通过ajax将选中的行数据传递到另一个数据表中?,php,jquery,ajax,wordpress,Php,Jquery,Ajax,Wordpress,我试图获取选中的行数据,但我不知道如何从提交函数传递它。因此,我可以将数据传递给另一个phpdatatable,以及在传递数据后如何检索数据 $('#submit_form').on('submit', function(){ //function to get the checkbox that is checked data and pass it to another php }); 我的html表格 <form id="submit_form" action="<?
php
datatable
,以及在传递数据后如何检索数据
$('#submit_form').on('submit', function(){
//function to get the checkbox that is checked data and pass it to another php
});
我的html表格
<form id="submit_form" action="<?php echo site_url('Test_product/import');?>">
<p align="right"><button name="import" type="submit" form="submit_form">Import </button></p>
<table id="import" width="100%">
<thead>
<tr>
<th><input name="select" id="select" type="checkbox" checked></th>
<th></th>
<th>Name</th>
<th>SKU</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th>Name</th>
<th>SKU</th>
</tr>
</tfoot>
</table>
</form>
因为我想将数据传递到另一个php文件。显示表和行的html。我已经编辑好了。那么现在您希望得到什么样的结果?在我看来,您发布的输出是您在postmy main中描述的行数据,用于将行数据传递到另一个php文件,例如test.php,这样我就可以在test.php上打印出datatable,因为我想将数据传递到另一个php文件。显示表的html和行。好的,我已经编辑了它。好的,那么现在您希望得到什么样的结果?在我看来,您发布的输出是您在postmy main中描述的行数据,它将行数据传递给另一个php文件example test.php,以便我可以在test.php上打印数据表
<script>
$(document).ready(function() {
var table = $('#import').DataTable({
bProcessing: true,
ajax: "localhost/product.php",
columns: [
{
data: 'id',
searchable: false,
orderable: false,
className: 'dt-body-center',
render: function (data, type, full, meta){
return '<input type="checkbox" name="' +data+ '"'+ 'checked>'; }
},
{data: 'photo'},
{data: 'name'},
{data: 'sku'}
]
});
$('#select').on('click', function(){
// Get all rows with search applied
var rows = table.rows({ 'search': 'applied' }).nodes();
// Check/uncheck checkboxes for all rows in the table
$('input[type="checkbox"]', rows).prop('checked', this.checked);
});
$('#submit_form').on('submit', function(){
var data = table.rows(this).data();
alert(data[0]);
});
});
</script>
{"data":[{"id":35,"name":"_testing_product_009","sku":"-","photo":""}]}