在ajax函数后刷新数据表

时间:2018-10-22 16:43:27

标签: javascript php html ajax datatable

我的数据表未重绘,但我正在调用.draw();函数...

我的HTML:

{Contactos}
                <tr>
                    <td>{IdContacto}</td>
                    <td >{NomeContacto}</td>
                    <td>{NumeroContacto}</td>
                    <td class="IdContacto" data-id="{IdContacto}"><a style="color: white; margin-left: 20px;" data-toggle="modal" data-target="#EditNumber" type="button" class="btn btn-success"> <i style="color: white; padding-right: 6px;" class="fa fa-edit"></i>Editar</a><a style="color: white; margin-left: 20px;" data-toggle="modal" data-target="#DeleteNumber" type="button" class="btn btn-danger"> <i style="color: white; padding-right: 6px;" class="fa fa-trash"></i>Eliminar</a></td>
                </tr>
                {/Contactos}

这是我的JS:

function InsertPhoneNumber(){
var Nome = document.getElementById("Nome").value;
var Numero = document.getElementById("Numero").value;

jQuery.ajax({
  type: "POST",
  url: 'http://localhost/projeto/index.php/Backoffice_Controller/InserirContactos',
  data: {Nome: Nome, Numero: Numero},
  success: function (response) {
    NumberTable.draw();
    console.log("success");
    console.log(response);
  },
  error: function(response){
    console.log("error");
    console.log(response); 
  }
});
}

数据表初始化:

var NumberTable = $('#table_id').DataTable({

"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bInfo": false,
"bAutoWidth": false,
"searching": false, 
 });

它会打印出成功消息,并将数据插入到我的数据库中,但是它没有给我任何错误,下面是她重绘了我的表,是否有帮助吗?

0 个答案:

没有答案