Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何通过ajax将选中的行数据传递到另一个数据表中?_Php_Jquery_Ajax_Wordpress - Fatal编程技术网

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":""}]}