recargar pagina modal mediante llenar example datos cerrar cargar bootstrap agregar actualizar ajax datatable populate

ajax - mediante - recargar pagina al cerrar modal bootstrap



Cargar datos de DataTable a través del botón Click (2)

Quiero llenar DataTable con un clic de botón. Inicialmente, la tabla de datos debe estar vacía:

var searchText = $("#textBox").val(); Table = $("#customerTable").dataTable({ data:[], "columns": [ {"data": "Id" }, { "data": "Name" }, { "data": "City" }, { "data": "Country" } ] //"serverSide": true });

y el botón clic:

$("#SearchButton").on("click", function (event) { $.ajax({ url: "/LoadCustomers", type: "post" }); Table.rows.add(result).draw(); });


Resuelto !!!

Mi mesa se ve así:

Table = $("#customerTable").DataTable({ data:[], columns: [ { "data": "CompanyId" }, { "data": "CompanyName" }, { "data": "City" }, { "data": "Country" } ], rowCallback: function (row, data) {}, filter: false, info: false, ordering: false, processing: true, retrieve: true });

Controlador de clic de botón:

$("#customerSearchButton").on("click", function (event) { $.ajax({ url: "", type: "post", data: { searchText: searchText } }).done(function (result) { Table.clear().draw(); Table.rows.add(result).draw(); }).fail(function (jqXHR, textStatus, errorThrown) { // needs to implement if it fails }); }


$( document ).ready(function() { Table = $("#datatable").DataTable({ data:[], columns: [ { data: "IAVDate" }, { data: "ShiftID" }, { data: "UserID" }, { data: "IAV" }, { data: "Type" }, { data: "IAV Value"} ], rowCallback: function (row, data) {}, filter: false, info: false, ordering: false, processing: true, retrieve: true }); start = jQuery("#start").val(); end = jQuery("#end").val(); $("#generate").on("click", function (event) { alert(''result''); $.ajax({ url: "<?php echo base_url(); ?>Report/IAV_sale", type: "post", "data": {"start":start,"end":end}, }).done(function (result) { Table.clear().draw(); Table.rows.add(result).draw(); }).fail(function (jqXHR, textStatus, errorThrown) { // needs to implement if it fails }); }); });

hey, no obtuve actualizar mi tabla de datos por el código anterior,

mi respuesta {"data": [{"IAVDate": "2017-03-17 07:08:32", "ShiftID": "30", "UserID": "111", "IAV": "45248022418", "Tipo": "efectivo", "valor de IAV": "1400"}, {"IAVDate": "2017-03-17 07:09:49", "ShiftID": "30", "ID de usuario": "111 "," IAV ":" 63094881690 "," Tipo ":" efectivo "," Valor IAV ":" 20 "}, {" IAVDate ":" 2017-03-17 07:12:14 "," ShiftID ": "30", "Id. De usuario": "111", "IAV": "55841613411", "Tipo": "tarjeta", "Valor IAV": "0"}, {"IAVDate": "2017-03-17 07 : 12: 16 "," ShiftID ":" 30 "," ID de usuario ":" 111 "," IAV ":" 27197239869 "," Tipo ":" efectivo "," Valor IAV ":" 0 "}, {" IAVDate ":" 2017-03-17 07:19:43 "," ShiftID ":" 30 "," UserID ":" 111 "," IAV ":" 82469287727 "," Tipo ":" efectivo "," IAV " Valor ":" 10 "}, {" IAVDate ":" 2017-03-17 07:20:33 "," ShiftID ":" 30 "," ID de usuario ":" 111 "," IAV ":" 22158170425 ", "Tipo": "efectivo", "Valor IAV": "200"}, {"IAVDate": "2017-03-17 07:20:44", "ShiftID": "30", "ID de usuario": "111 "," IAV ":" 91852461457 "," Tipo ":" efectivo "," Valor IAV ":" 50 "}, {" IAVDate ":" 2017-03-17 07:20:50 "," ShiftID ": "30", "Id. De usuario": "111", "IAV": "3906686807", "Tipo": "efectivo", "Valor IAV": "20"}, {"IAVDate": "2017-03-17 07 : 20: 52 "," ShiftID ":" 30 "," ID de usuario ":" 1 11 "," IAV ":" 28281616952 "," Tipo ":" efectivo "," Valor IAV ":" 200 "}, {" IAVDate ":" 2017-03-17 07:22:18 "," ShiftID " : "30", "Id. De usuario": "111", "IAV": "20432041716", "Tipo": "efectivo", "Valor IAV": "100"}, {"IAVDate": "2017-03-17 07:22:21 "," ShiftID ":" 30 "," UserID ":" 111 "," IAV ":" 43137123170 "," Tipo ":" efectivo "," Valor IAV ":" 50 "}, { "IAVDate": "2017-03-17 07:22:26", "ShiftID": "30", "UserID": "111", "IAV": "99290115936", "Tipo": "efectivo", " IAV Value ":" 5 "}, {" IAVDate ":" 2017-03-17 07:23:14 "," ShiftID ":" 30 "," UserID ":" 111 "," IAV ":" 69687310655 " , "Tipo": "tarjeta", "Valor IAV": "700"}, {"IAVDate": "2017-03-17 07:24:21", "ShiftID": "30", "ID de usuario": " 111 "," IAV ":" 5706858910 "," Tipo ":" tarjeta "," Valor IAV ":" 700 "}, {" IAVDate ":" 2017-03-17 07:25:44 "," ShiftID " : "30", "ID de usuario": "111", "IAV": "25842193589", "Tipo": "efectivo", "Valor IAV": "47"}]}