【发布时间】:2018-08-31 16:43:25
【问题描述】:
我有一张订单表,我尝试每 5 秒刷新一次表,而不刷新整个页面。 经过一番研究,我发现我需要使用这个功能:
<script>
$(document).ready(function(){
refreshTable();
});
function refreshTable(){
$('#the_div_you_need_to_refresh').load('path', function(){
setTimeout(refreshTable, 5000);
});
}
问题是我真的不明白我应该在 .load('path') 中放什么,因为如果我这样写,它会使我的标题加倍并且会给我一个错误:
.load('<?php echo base_url('page name')?>',function(){
<--function content-->
})
我的查看页面是这样的:
<h2><?= $title;?></h2>
<div id="table_container">
<table class="table table-striped table-hover" id="orders_table">
<thead>
<--content-->
</thead>
<tbody>
<?php foreach($orders as $order):?>
<tr class="active">
<--content-->
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
我的控制器是这样的:
public function index(){
if(!$this->session->userdata('logged_in')){
redirect('users/login');
}
$data['title'] = "Comenzi";
$data['orders'] = $this->order_model->get_orders();
$this->load->view('templates/header');
$this->load->view('orders/comenzi',$data);
$this->load->view('templates/footer');
}
你能解释一下我该怎么做吗?
【问题讨论】:
标签: php jquery ajax codeigniter refresh