title: how to get the dynamic column header and result from ajax call in jquery datatable
body: <p>I want to display the dynamic column header along with the results in datatable.In aaData and aoColumns attributes has to get result data and columns name from ajax call, Please suggest me how to do this or give me some alternate solution to get the dynamic data and column header from ajax call, Here is my code.:</p>
  
  <pre><code>var $table=$('#MSRRes').dataTable( {
      "bFilter": false,                         
      "bDestroy": true,
      "bDeferRender": false,
      "bJQueryUI": true,
      "oTableTools": {
          "sSwfPath": "swf/copy_cvs_xls_pdf.swf",
      },
      "sDom": 'TC&lt;"clear"&gt;l&lt;"toolbar"&gt;frtip',
      "ajax" :{
          url: 'getResult.php',
          type: "POST",
          data: {
             formData:postData,
           }  
      },
      "aaData": results.DATA ,
      "aoColumns": [ column_names ]
  });
  </code></pre>
  
  <p>Here is my ajax call to get the result data and column names to be display:</p>
  
  <pre><code>$result=$afscpMsrMod-&gt;getAdvanceSearchResults($colCond,$whereCond,$having);
  foreach($cols as $col) {
      array_push($colArr, $colnames);
  }
  $colJson= json_encode($colArr);
  $newarray = array(
      "draw"            =&gt; 1,
      "recordsTotal"    =&gt; sizeof($result),
      "recordsFiltered" =&gt; sizeof($result),
      "data"            =&gt; $result,
      "COLUMNS"         =&gt; $colJson   
  );
  echo json_encode($newarray);
  </code></pre>