I am using Jquery Datatables to load an array of array of data (aaData) obtained via ajax call from server side. I don't want to pull whole of the data at once rather I need to make ajax request for loading data every time user clicks "prev" or "next" in Datatables pagination.
How can this be achieved ?I want to make an ajax call and fetch results on the fly for that page only.
Below is the javascript code where in I am making a call.
$.ajax({
type: "GET",
url: "ajaxBacklog",
contentType: 'application/json',
data: null,
dataType: 'json',
success: function(json){
oTable = $("#backlogTable").dataTable({
"aaData": json.aaData,
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"bRetrieve": true,
"bPaginate": true,
"bStateSave": true,
"bSort": true,
"aaSorting": [[ 4, "desc" ]],
"iDisplayLength": 25,
"oLanguage": {
"sProcessing": "<img src='resources/images/loader.gif'/>",
"sEmptyTable": "No records found."
},
"aoColumns": [
{ "sClass": "alignCenter"},
{ "sClass": "left"},
{ "sClass": "left"},
{ "sClass": "left"},
{ "sType": 'date-uk', "sClass":"datecolumn"},
{ "sType": 'date-uk', "sClass":"datecolumn"},
{ "sClass": "left"},
{ "sClass": "left"}
],
"error": function() {
alert("Failed to load Data");
}
});
}
}
);
I have also followed the server side processing of datatables as well but nothing is working.