DOM response instead of JSON response

DOM response instead of JSON response

sandyridgeracersandyridgeracer Posts: 1Questions: 0Answers: 0
edited January 2013 in General
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??

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    No - it is not currently possible to respond with an HTML string and have DataTables use that. You would need to extract the data yourself and then pass it into DataTables.

    Allan
This discussion has been closed.