I load the view in Which I want to display fetch record from the database through the ajax JSON request.But it's not showing the record.
Here is my view code
<div class="col-md-6" id="hodm_table">
<table class="table table-striped table-hover table-responsive">
<thead>
<tr>
<th>Task Name</th>
<th>Director</th>
<th>Duration</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach($result as $hodm) { ?>
<tr>
<td><?php echo $hodm->t_name;?></td>
<td><?php echo $hodm->director;?></td>
<td><?php echo $hodm->duration;?></td>
<td><?php echo $hodm->status;?></td>
<?php } ?>
</tbody>
</table>
</div>
</div>
<script type='text/javascript' language='javascript'>
$(document).ready(function(){
$.ajax({
url:"<?php echo base_url();?>digital/dashboard/dig_short_hodm_table",
type: 'POST',
dataType: 'JSON',
success:function (data) {
$('#hodm_table').html(data);
}
});
event.preventDefault();
});
</script>
Here is my model
public function get_hodm()
{
return $this->db->get("hodm");
}
Here is my controller
public function dig_short_hodm_table(){
$data['result']=$this->pojo->get_hodm();
return json_encode($data);
}
When I load my page then it showing the error
Message: Undefined variable: result
I want to when view load it fetch the record from the database and show in the view tables.