Pass data value to ajax request - DataTables 1.10.0
Pass data value to ajax request - DataTables 1.10.0
APonciano
Posts: 4Questions: 1Answers: 0
Hi,
I'm missing something here and would appreciate the help. I need to send a information to my server page using AJAX data, but i just can't manage. I tried all the examples in (http://datatables.net/reference/option/ajax) with out success. can some one PLEASE send an example. What I need to achieve is something like this:
"ajax": {
"url": rootUrl + "Usuario/listAll",
"type": "POST",
"data": {"MYINFO":"Value"}
},
Thanks for the help>
This discussion has been closed.
Answers
Just adding my entire configuration for datatables.
var t = $('#datatable').dataTable( {
"oTableTools": {
"sSwfPath": "js/jquery.datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
"sTitle":"Usuarios",
"aButtons": [
{
"sExtends": "text",
"sButtonText": 'Novo',
"fnClick": function( nButton, oConfig ) {
console.log('novo registro');
$('#legendaModal').text('Novo Usuário');
$("#formulario")[0].reset();
$("#inputIdUsuario").val("");
$("#errorServer").html("");
$("#errorServer").hide();
$("#errorEmpty").hide();
$("#novoModal").niftyModal('show');
}
},
{
"sExtends": "collection",
"sButtonText": 'Exportar <span class="caret" />',
"aButtons": [ "copy", {
"sExtends": "xls",
"sFileName": "Usuario - *.xls"
}, {
"sExtends": "pdf",
"sFileName": "Usuario - *.pdf"
},"print" ]
},
{
"sExtends": "text",
"sButtonText": 'Mostrar bloqueados',
"sButtonClass" : "toggle-row-display",
"fnClick": function( nButton, oConfig ) {
console.log('Mostrat Todos');
$(nButton).toggleClass('selected');
}
}
],
"fnRowSelected": function ( nodes ) {
alert( 'The row with ID '+nodes[0].id+' was selected' );
},
},
"sDom": 'T<"clear">lfrtpi',
"autoWidth": false,
"language": {
"lengthMenu": "Mostrar _MENU_ registros por página",
"zeroRecords": "Nenhum registro localizado - desculpe",
"info": "Mostrando página _PAGE_ de _PAGES_",
"infoEmpty": "Sem registros",
"emptyTable": "Sem registros para visualizar" ,
"infoFiltered": "(filtrando _MAX_ do total de registros)",
"search": "Procurar: ",
"loadingRecords": "Por gentileza aguarde - CARREGANDO...",
paginate: {
first: "Primeiro",
previous: "Anterior",
next: "Próximo",
last: "Último"
},
Hi, just figured it out, the data is being sent correctly, but since I`m using SLIM framework is is not being passed the way the framework is expecting.. I need to send the data as a JSON structure.. any hints?
Just figured out a workaround.. changed the line 2336 in datatable.js to ( "data": JSON.stringify(data) )