を再ロードするために使用するレイアウト コントローラ
class Admin extends CI_Controller
{
public function dashboard()
{
$data['main'] = "admin/header";
$data['instant_reqtotal'] = $this->admin_model->getreqtotal();
$this->load->view('admin/dashboard',$data);
}
}
ビュー
<div id="instanthirewidget">
<?php echo $instant_reqtotal; ?>
</div>
モデル
public function getreqtotal()
{
$this->db->where('status','pending');
$query=$this->db->get('instanthire');
return $query->num_rows();
}
スクリプトを乱すことなく、div要素をリフレッシュする方法を教えてもらえますこれは、ビュー内でビューを返すために起こります。
public function dashboard()
{
$data['main'] = "admin/header";
$instant_reqtotal = $this->admin_model->getreqtotal();
echo $instant_reqtotal;
exit;
}
$.ajax({
url : '...',
method : '...',
data : {...},
success : function(response) // response contains the $instant_reqtotal value in it
{
$('#instanthirewidget').html(response);
}
});
このためには、ajaxの電話番号 –
ちょうど正しいdashboard.phpです。それはダッシュボードではないはずですか? –
@Naveed Ramzan申し訳ありませんが、入力エラーでした。 – user3732711