I need to save the state of pagination, sorting & search inputs, ultimately utilizing Laravel and an API instead of the database. I'd rather not use yajra/laravel-datatables as I've already created the complex DataTable I need.
Example
<script type="text/javascript">
$(document).ready(function () {
var table = $('#stackoverflow-datatable').DataTable({
"stateSave": true,
"stateSaveCallback": function (settings, data) {
$.ajax({
"url": "/api/save_state",
"data": data,
"dataType": "json",
"success": function (response) {}
});
},
"stateLoadCallback": function (settings) {
var o;
$.ajax({
"url": "/api/load_state",
"async": false,
"dataType": "json",
"success": function (json) { o = json; }
});
return o;
}
});
});
</script>
The URLs: "/api/load_state" point to a Laravel route, and the routes point to specific methods on the Controller. I see that it's calling the methods correctly. However, I don't know what it's sending me or how I change the JS to tell it to give me what I need. Once I have an on Object (or something), send it back and apply it when the user goes back to the page.
