How to use fnServerData to modify the server response?
How to use fnServerData to modify the server response?
nmendoza
Posts: 3Questions: 1Answers: 0
I want to make some validation of my json object this is my code:
$(document).ready( function() {
$('#table').dataTable( {
"bProcessing": true,
"bServerSide": true,
"columns": [{ "data": "id" },{ "data": "codigo" },{"data": "nombre" },{ "data": "pais" }],
"fnServerData": function ( sSource, aoData, fnCallback) {
sSource= "/gdoc/abm/ciudad/rest";
$.getJSON( sSource, aoData, function (json) {
jQuery.each(json.aaData, function(index, item) {
jQuery.each( item, function( key, value ) {
//some conditions
item.key = "";
});
});
fnCallback(json);
});
}
});
});
But the Datatable show the json without any modification. What it's wrong with this code?
This discussion has been closed.
Answers
I also try this:
What stupid, I was creating the key "key" in item. I solved it. Thanks