2

I am trying to render column contents with ajax response but it doesn't display anything in the column despite ajax response returning data,

{
    "width": "20%","targets": 6,
    "defaultContent": '',
    "render": function ( data, type, row ) {
        if(row.colData !=''){
            $url="server request url";
            var ret= row.colData
            var aydGuid=row.guid;
            var params = {relatedHID:ret,guid:aydGuid};
                $.ajax({
                    url: $url,
                    async: true,
                    data: jQuery.param(params),
                    dataType:'html'
                    }).done(function( data ) {
                        alert(data) //displays response  
                        return data //does nothing                                      
                    });
}
3
  • Possible duplicate of How do I return the response from an asynchronous call? Commented Aug 12, 2016 at 22:23
  • Guess you didn't read the post well. I don't have problem in getting response from AJAX. My problem is ajax response is not rendering into data table(datatables.net) Commented Aug 12, 2016 at 23:56
  • Ask yourself this question: when you call return data, where do you think it's being returned to? Commented Aug 13, 2016 at 2:35

1 Answer 1

4

Got it working,

    {
        "width": "20%","targets": 6,
        "defaultContent": '',
        "render": function (data, type, row, meta) {
        $urlAgent="url";
        var ret= data.join('^')
        var aydGuid=row.guid;
        var params = {relatedHID:ret,guid:aydGuid};
        var currentCell = $("#tbl_DT").DataTable().cells({"row":meta.row, "column":meta.col}).nodes(0);
           $.ajax({
                url: $urlAgent,
                data: jQuery.param(params),
                dataType:'html'
          }).done(function (data) {                                                                              
                $(currentCell).html(data);
          });
          return null;
    }
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.