Php 数据表中的fnDraw不工作

Php 数据表中的fnDraw不工作,php,ajax,twitter-bootstrap,datatables,datatables-1.10,Php,Ajax,Twitter Bootstrap,Datatables,Datatables 1.10,我使用的是DataTable1.10.10和datatable的引导风格。我有两个PHP文件,一个是driver-list.PHP和driver-edit.PHP。但是driver-edit.php只为模式窗口编码。当我单击edit按钮时,它将id传递给driver-edit.php。并在driver-list.php中打开一个模态窗口。但当我单击driver-edit.php的提交按钮时,它在单击提交按钮后不会更新 我尝试了fnDraw、fnReloadAjax、ajax.reload函数。但

我使用的是DataTable1.10.10和datatable的引导风格。我有两个PHP文件,一个是driver-list.PHP和driver-edit.PHP。但是driver-edit.php只为模式窗口编码。当我单击edit按钮时,它将id传递给driver-edit.php。并在driver-list.php中打开一个模态窗口。但当我单击driver-edit.php的提交按钮时,它在单击提交按钮后不会更新

我尝试了fnDraw、fnReloadAjax、ajax.reload函数。但它总是失败

driver-list.php

driver-edit.php


对不起,在类型下:POST,formData=newformdatathis。为了方便,我删除了这个。你打电话给fnDraw时会发生什么?fnDraw不会重新生成SQL脚本,也不会重新加载页面。我需要,当我删除或编辑一个数据时,必须在单击按钮后更新表。例如location.reload代码将重新加载整个页面。但我不需要重新加载整个页面。只有在编辑或删除@davidkonradYes之后,我才需要刷新更新表,我明白这一点。我想问的是,你认为这是如何实现的?在您的情况下,dataTables既不负责加载数据也不负责创建表——这是由您的服务器端用代码完成的,那么您认为dataTables应该如何使用fnDraw从驱动程序完成的服务器端重做$que=SELECT*?正如您的代码一样,location.reload是您唯一的支持。是吗?哦,真的谢谢你。我不知道这个问题。我没有解决这个问题的办法吗?或者$'table'.loadlocation.href,此代码仅第一次有效,这意味着当我第一次单击时,第二次它不起作用,如果您有任何解决方案,请让我知道。因为没有人喜欢在每次更新或删除@davidkonrad时重新加载页面
<div class="container">
    <div class="well">
        <div class="col-lg-3"><label class="control-form">Driver-List</label></div>

        <div class="col-lg-offset-11"><button type="submit" class="btn btn-primary">Add New</button></div>

    </div>

    <div class="table-responsive">
    <table class="table table-hover myTable" id="data-table">
        <thead>
            <tr>
                <th>No</th>
                <th>First name</th>
                <th>Last Name</th>                   
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
                include 'inc/connection.php';

                $que="SELECT * FROM driver";
                $query_run=mysqli_query($con,$que);
                $no=1;

                while($row=mysqli_fetch_array($query_run))
                {               
            ?>
                <tr>
                    <td><?php echo $no++; ?></td>
                    <td><?php echo $row['first_name']; ?></td>
                    <td><?php echo $row['last_name']; ?></td>
                    <td><div class="btn-group"><a class='Edit btn btn-primary' onclick="javascript: editaxa('<?php echo $row['driver_id'];?>');" data-toggle="modal" href="#form_modal" data-target="#myModal" data-Id="<?php echo $row['driver_id'];?>">Edit</a></div>
    </td>                        

                </tr>
            <?php
                }
                mysqli_close($con);
            ?>
        </tbody>
    </table>
    </div>
</div>


<div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">

        </div>
    </div>
</div>



 <script>
$(document).ready(function() {
     var dt=$('#driver-list').DataTable();
} );
function editaxa(xx){

    var Id_Edit=xx;

    $.ajax({
        url:"views/driver/driver-edit.php?Id="+Id_Edit,
        cache:false,
        success:function(result){
            $(".modal-content").html(result);

    }});
}   

</script>
<?php
$id=$_GET['Id'];

include '../../inc/connection.php';

$query="SELECT * FROM driver WHERE driver_id='$id'";
$query_run=mysqli_query($con,$query);
$row=mysqli_fetch_array($query_run);

?>


<div class="modal-body">


    <form class="form-horizontal" role="form" action="" method="POST" enctype="multipart/form-data">
        <div class="form-group">
            <div class="row">
                <div class="col-xs-offset-1 col-lg-2">                                                
                    <label class="control-label">First Name</label>                            
                </div>

                <div class="col-lg-3">
                    <div class="input-group">                                
                        <input type="text"  id="first_name" class="form-control"  name="first_name" requi red="requi red" autocomplete="off" value="<?php echo $row['first_name']; ?>" />
                        <span class="input-group-addon"><i class="" id="a"></i></span> 
                    </div>
                </div>


                <div class="col-lg-2">
                    <label class="control-label">Last Name</label>
                </div>


                <div class="col-lg-3">
                    <div class="input-group">   
                        <input type="text"  id="last_name" class="form-control"  name="last_name"  requi red="requi red" autocomplete="off" value="<?php echo $row['last_name']; ?>"/>
                        <span class="input-group-addon"><i class=""></i></span> 
                    </div>
                </div>
                <br />
            </div>
        </div>


        <div class="modal-footer">

            <div class="form-group">
                <div class="row">
                    <div class="col-xs-offset-3 col-lg-2">
                        <button class="btn btn-success-outline btn-block" id="submit" type="submit">Submit</button>
                    </div>
                 </div>
            </div> 
        </div>
    </form>
</div>


<script>
$(document).ready(function(e) { 
    formData =new FormData(this)
        $.ajax({
            url: "actions/driver/driver-edit.php",
            type: "POST",
            data: formData,
            contentType: false,
            cache: false,
            processData:false,
            success: function(data)
            {
                    $('#myModal').modal('hide');                       
                    dt.fnDraw();     // dt is defined in driver-list.php
            },
            error: function(data) 
            {
                alert(console.log(data))
            }
       });
        }
    }));


});




</script>