i want to display data from ajax into model show with echo php, i have made ajax and have working no errors.
this is my model
public function detail($id_branch) {
$this->db->select('TR_BRANCH.*');
$this->db->from('TR_BRANCH');
$this->db->where('BRANCH_ID', $id_branch);
$query = $this->db->get();
return $query->result();
}
my controller
Public function detail($id_branch){
$data = $this->main_model->detail($id_branch);
echo json_encode($data);
$this->load->view('template/pages/home_index', $data);
}
my ajax
function coba(id_branch) {
$('#placeholder').hide();
$('#placeholder').show(function(){
$.ajax({
url:"<?php echo base_url() ?>home/detail/" + id_branch,
success(res){
// alert(id_branch)
}
})
});
}
my view
<div id="placeholder">
<div class="row">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<p><?php echo $data->DISPLAY_NAME; ?></p>
</div>
</div>
</div>
if i
<?php echo $data->DISPLAY_NAME; ?>
in my modal, i'm getting error like Undefined variable: data. result data json_encode already appear in network based id_branch. how to fix it? pls help