can someone show me an example of display detail with ajax
can someone show me an example of display detail with ajax
alderhernandez
Posts: 33Questions: 11Answers: 1
can someone show me an example of display detail with ajax,
I've been trying but I have not been able to show the details with ajax
here is mi code
$('#tblReporte').on('click', 'tbody tr .detalle', function () {
var table = $('#tblReporte').DataTable();
var tr = $(this).closest('tr');
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');
}
} );
function format ( d ) {
// `d` is the original data object for the row
$.ajax({
url: 'ajaxReportes2',
type: 'POST',
dataType: 'json',
success: function(msg)
{
var ii=0;
$.each(msg, function(key,val)
{
for (var i = 0; i < key.length; i++) {
alert(msg.hola2);
};
});
}
});
}
the alert shows me undefined
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The key is that the
format
function needs to return something for therow().child()
function to show. At the moment it is returningundefined
.Why I typically do is create a
div
with a unique id and return that (possibly with a "loading" message in it. Then in the Ajaxsuccess
callback insert your content into that unique id.Allan