DOM response instead of JSON response
DOM response instead of JSON response
sandyridgeracer
Posts: 1Questions: 0Answers: 0
HI Alan,
First i would like to mention that the plugin is awesome.
As the title says, I am trying to fetch the data using AJAX. Datatable relies on the json response.(I cannot use JSON response due to some restrictions)
I am trying to send a complex dom response from the server.This is my Datatable initialization code.
[code]
var oTable1 = $(".listCustomer").dataTable({
"iDisplayLength": 25,
"bSort": true,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"bRetrieve":true,
"bDestroy":true,
"sAjaxSource": "dataTablesSource",
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
$.ajax({
"dataType": 'text',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(data)
{
$("#tableBody").html(data)
//oTable1.fnDraw(false);
}
});
}
});
[/code]
I am getting the dom response,but the pagination is lost.
I know the iTotalDisplayRecords has to be set for the pagination to work.
How do i set it??
More importantly, is this technique correct??
First i would like to mention that the plugin is awesome.
As the title says, I am trying to fetch the data using AJAX. Datatable relies on the json response.(I cannot use JSON response due to some restrictions)
I am trying to send a complex dom response from the server.This is my Datatable initialization code.
[code]
var oTable1 = $(".listCustomer").dataTable({
"iDisplayLength": 25,
"bSort": true,
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"bRetrieve":true,
"bDestroy":true,
"sAjaxSource": "dataTablesSource",
"fnServerData": function (sSource, aoData, fnCallback, oSettings) {
$.ajax({
"dataType": 'text',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(data)
{
$("#tableBody").html(data)
//oTable1.fnDraw(false);
}
});
}
});
[/code]
I am getting the dom response,but the pagination is lost.
I know the iTotalDisplayRecords has to be set for the pagination to work.
How do i set it??
More importantly, is this technique correct??
This discussion has been closed.
Replies
Allan