如何在方法/动作执行上显示加载图像


How to show loading image on method/action executing

我是PHP/CodeIgniter的新手。

我想在动作/方法开始执行时显示加载图像,在页面加载结束时它将隐藏/停止显示加载图像。

下面是我在控制器中的动作:

public function Index() {
    $this->data['Shibirarthis'] = $this->Shibirarthi_m->get_by(array('IsDeleted !=' => 1));
    $this->data['subview'] = 'Shibirarthi/Index';
    $this->load->view('_layout_main', $this->data);
}

把这个放到HTML页面中:

<div id="loader">
   <img src=""> //put image you want
</div>
Javascript

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(function(){
    $('#loader').fadeOut();
});
</script>

希望这将帮助你…:)