can row detail info got by ajax?

can row detail info got by ajax?

zh.chao163zh.chao163 Posts: 4Questions: 0Answers: 0
edited July 2009 in General
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!

Replies

  • zh.chao163zh.chao163 Posts: 4Questions: 0Answers: 0
    aha, i know what's wrong here, and it works now anyway.
  • soberspsobersp Posts: 28Questions: 0Answers: 0
    What did you do to make it work ??
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi sobersp,

    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
  • pawelpawel Posts: 14Questions: 0Answers: 0
    edited October 2010
    What I did for this issue was call the fnOpen function in the call back function so u don't have to force the code to be synchronous and u can open more than one detail every time.

    Regards,
    Pawel.
This discussion has been closed.