如何显示我的桌子?

This is my index.php view were my table is placed

<table class="striped">
              <thead>
                <tr>
                    <th>Id</th>
                    <th>Name</th>
                    <th>Address</th>
                    <th>Created at</th>
                </tr>
              </thead>

              <tbody id="showdata">
                <!--<tr>
                  <td>1</td>
                  <td>Alvin</td>
                  <td>Eclair</td>
                  <td>$0.87</td>
                  <td>
                    <a href="javascript:;" class="waves-effect waves-light btn">Edit</a>
                    <a href="javascript:;" class="waves-effect waves-light btn">Delete</a>
                  </td>
                </tr>-->
              </tbody>
</table>

This my ajax script placed on index.php

function showAllEmployee() {
      $.ajax({
        type: 'ajax',
        url: '<?php echo base_url(); ?>index.php/Employee/showAllEmployee',
        async: false,
        dataType: 'json',
        success: function(data) {
          //console.log(data);
          var html = '';
          var i;
          for (i=0; i<data.length; i++) {
            html += '<tr>'+
                  '<td>'+data[i].emp_id+'</td>'+
                  '<td>'+data[i].name+'</td>'+
                  '<td>'+data[i].address+'</td>'+
                  '<td>'+data[i].created_at+'</td>'+
                  '<td>'+
                    '<a href="javascript:;" class="waves-effect waves-light btn" style="margin-right: 10px;" data="'+data[i].emp_id+'">Edit</a>'+
                    '<a href="javascript:;" class="waves-effect waves-light btn" data="'+data[i].emp_id+'">Delete</a>'+
                  '</td>'+
                '</tr>';
          }
          $('#showdata').html(html);
        },
        error: function() {
          alert('Could not get data from database');
        }

      });
    }

This is what i have on my employee controller

public function showAllEmployee()
    {
        $result = $this->em->showAllEmployee();
        echo json_encode($result);
    }

This is my model

public function showAllEmployee()
    {
        $this->db->order_by('created_at', 'desc');
        $query = $this->db->get('tbl_employees');
        if($query->num_rows() > 0) {
            return $query->result();
        } else {
            return false;
        }
    }

Whenever i refresh the page the data wont display instead i run into an error could not get the data from the database which is the condition i set on my ajax script what could be wrong pls help

set header as JSON type in the controller change your controller to

public function showAllEmployee(){
    $result = $this->em->showAllEmployee();
    $this->output
        ->set_content_type('application/json')
        ->set_output(json_encode($result));
}