can row detail info got by ajax?
can row detail info got by ajax?
zh.chao163
Posts: 4Questions: 0Answers: 0
hi,
i saw the example page,"http://datatables.net/1.5-beta/examples/api/row_details.html and changed the code as follows:
function fnFormatDetails ( nTr )
{
var iIndex = oTable.fnGetPosition( nTr );
var aData = oTable.fnSettings().aoData[iIndex]._aData;
var sOut;
$.get("/check/getCheckInfo.php", { "flowId": aData[1] },function(data){
sOut = data;
});
return sOut;
}
when i clicked the image to see the detail, what i can see is the message 'undefined' in the detail area ,however i have confirmed the data from the server is correct. what's wrong here? can the detail function support ajax ?
thanks a lot!
i saw the example page,"http://datatables.net/1.5-beta/examples/api/row_details.html and changed the code as follows:
function fnFormatDetails ( nTr )
{
var iIndex = oTable.fnGetPosition( nTr );
var aData = oTable.fnSettings().aoData[iIndex]._aData;
var sOut;
$.get("/check/getCheckInfo.php", { "flowId": aData[1] },function(data){
sOut = data;
});
return sOut;
}
when i clicked the image to see the detail, what i can see is the message 'undefined' in the detail area ,however i have confirmed the data from the server is correct. what's wrong here? can the detail function support ajax ?
thanks a lot!
This discussion has been closed.
Replies
I'm guessing that the $.get() call in asynchronous, therefore the return of sOut is occurring before it is actually assigned in the callback function. One way around this is to make the call synchronous, another might be to use a poll/wait to see if the value has been assigned.
Regards,
Allan
Regards,
Pawel.