title: Yii2 + jQuery DataTable + Ajax
body: <p>I am new to Yii and need some help.</p>
  
  <p>I am using Yii2.</p>
  
  <p>I have a page where I use DataTable trying to populate it with ajax from the database.
  The data returned from the controller does not display in the table.</p>
  
  <p>I installed the DataTable extension.
  I installed yadcf</p>
  
  <p>My html:</p>
  
  <pre><code> &lt;table class="table table-bordered" id='invoicesTbl'&gt;
     &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Customer&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>My ajax controller has this function:</p>
  
  <pre><code>public function actionGetinvoices() {
      $company_id = isset($this-&gt;dataBody['company_id'])?$this-&gt;dataBody['company_id']:null;
  
      if ($company_id === null) 
          $this-&gt;sendResponse(501,array('error'=&gt;'Invalid company found'));
  
      $output = array();
      $output['aaData'] = '';
  
      $invoices = InvoiceDiscountReport::getInvoices($company_id);
  
      $aColumns = array('invoice_discount_report__debtor__name');
  
      if(!empty($invoices))
      {
          foreach($invoices as $inv)
          {
              $row = array();
              for($i=0; $i&lt;count($aColumns); $i++)
              {
                      $row[] = $inv[$aColumns[$i]];
  
              }
  
              $output['aaData'][] = $row;
          }
      }
  
      $this-&gt;sendResponse(200,$output);
  }
  </code></pre>
  
  <p>My js file has this code:</p>
  
  <pre><code>var myTable = $('#invoicesTbl').DataTable({
      retrieve: true,
      paging: false,
      "language": {
          "emptyTable": "There are no invoices for the company",
      "bProcessing": true,
      "bDestroy": true,
      "sAjaxSource": '/api/dashboard/getinvoices&amp;company_id=49',
      "bAutoWidth": true,
      "aaSorting": [[ 0, "asc" ]],
      "aoColumns": [
          { "bSortable": true, "sWidth": "100%" },
      ],
  }
  });
  
  yadcf.init(myTable, [
  {column_number : 0, filter_type: "text", text_data_delimiter: ","}
  ],'footer');
  });
  </code></pre>
  
  <p>The data returned from my controller looks like this:
  {"aaData":[["SIGAL ZAHAVI"]]}</p>
  
  <p>What I get is an empty table with: There are no invoices for the company.</p>
  
  <p>Can someone please help me and tell what am I doing wrong?</p>
  
  <p>Thank you </p>