如何添加一些ajax來加載我的視圖部分?我已經完成了刪除/添加和更新Ajax。如何使用CodeIgniter添加AJAX來從數據庫加載我的數據
現在我不知道如何加載數據而無需刷新瀏覽器。每次我做刪除/添加和更新,我需要先刷新我的瀏覽器才能看到結果。我知道它會通過從數據庫自動加載數據而不刷新瀏覽器來解決問題。
型號
public function getManufacturerRecord(){ //view data
$this->db->select('*')
->from('manufacturer');
$query = $this->db->get();
return $result = $query->result();
}
控制器
public function manufacturer_list(){
if($this->session->userdata('is_logged_in')){
$result['data'] = $this->manufacturer_model->getManufacturerRecord();
$this->load->view('../template/header');
$this->load->view('manufacturer', $result);
$this->load->view('../template/footer');
} else {
redirect('main/restricted');
}
}
查看
<div id="navscroll">
<table class="table-condensed table-bordered table-striped table-hover">
<thead>
<tr>
<th>ID</th>
<th>Manufacturer</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if(!empty($data)):
foreach($data as $row) { ?>
<tr>
<td><?=$row->id;?></td>
<td><?=$row->brand;?></td>
</tr>
<?php } else : ?>
<tr>No Records Found!</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
你能來聊天。我想解決你的問題,但我需要更多關於你工作的信息。點擊鏈接http://chat.stackoverflow.com/rooms/137124/codeigniter –
嗨,我已經在聊天先生。 –