how transfer data from php (ajax) to row details

how transfer data from php (ajax) to row details

grzenekkgrzenekk Posts: 2Questions: 0Answers: 0
edited December 2011 in General
[code]


function fnFormatDetails ( oTable, nTr)
{
var aData = oTable.fnGetData( nTr );
$.ajax({
url : '/kurier/inc/datadetail.php',
data: 'nrp='+aData[4],
dataType: "json",
type: 'POST',
success: function(data) {

dane = data;

},
error: function(error) {

alert('blad'+error);
}

});


var sOut = '';
sOut += 'Status przesylki nr:'+aData[1]+' '+aData[4]+'';
sOut += 'Opis:'+dane[0]+'';
sOut += 'Data aktualizacji:'+dane[1]+'';
sOut += '';

return sOut;
}

$(document).ready(function() {
/*
* Insert a 'details' column to the table
*/
var nCloneTh = document.createElement( 'th' );
var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = '';
nCloneTd.className = "center";

$('#datatables thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );

$('#datatables tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );

/*
* Initialse DataTables, with no sorting on the 'details' column
*/
var oTable = $('#datatables').dataTable( {
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
],
"sPaginationType":"full_numbers",
"aaSorting": [[1, 'asc']],
"bJQueryUI":true,
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"aButtons": [
"copy", "csv", "pdf",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "pdf" ]
}
]
}

});

/* Add event listener for opening and closing details
* Note that the indicator for showing which row is open is not controlled by DataTables,
* rather it is done here
*/
$('#datatables tbody td img').live('click', function () {
var nTr = this.parentNode.parentNode;


if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "/kurier/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "/kurier/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
} );

} );

[/code]
Where should I insert the $ ajax {} code to list the correct information for each field. After development of the second field displays the ID data of the previous click. The problem is with aData
This discussion has been closed.