jquery datatable get data array
var table = $('#example').DataTable();
var plainArray = table
.data()
.toArray();
jquery datatable get data array
var table = $('#example').DataTable();
var plainArray = table
.data()
.toArray();
jquery datatable ajax get data
DataTables Example Using an Ajax Callback
The DataTables ajax option, here is a common way to retrieve
dynamic data from a source, for loading into a table.
$('#example').dataTable( {
"ajax": {
"url": "https://myurl.goeshere.com/mydata",
"type": "POST",
"dataSrc": "my_data"
}
} );
However, you can also use a function with the DataTables ajax option,
instead of an object. Here is an example:
$(document).ready(function() {
var table = $('#demo').DataTable( {
ajax: function (data, callback, settings) {
$.ajax({
url: "http://localhost:7000/ajax-employee-objects",
}).then ( function( json, textStatus, jqXHR ) {
json["data"] = json["row_objects"];
delete json["row_objects"];
//console.log(textStatus); // "success"
//console.log(json.extra_data.foo); // "bar"
callback(json);
});
},
columns: [
{ data: "name" },
{ data: "position" },
{ data: "office" },
{ data: "extn" },
{ data: "start_date" },
{ data: "salary" }
]
});
} );
Github NathanNoSudo
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us