我如何才能从分页url加载数据,而不是用codeigniter 4和jquery ajax渲染页面?
我的意思是只返回tr和td标签而不是页面的完整html的方法
这是我的代码,提前感谢
分页导航布局
<?php $pager->setSurroundCount(1); ?>
<div id="pagerRumah" class="row" style="position: sticky; bottom: 0; background: #ffffff;">
<div class="col-md-6 align-self-center">
<p id="dataTable_info" class="dataTables_info" role="status" aria-live="polite">Halaman <?= $pager->getCurrentPageNumber() ?> dari <?= $pager->getPageCount() ?></p>
</div>
<div class="col-md-6">
<nav class="d-lg-flex justify-content-lg-end dataTables_paginate paging_simple_numbers">
<ul class="pagination" style="overflow-y:auto;">
<li class="page-item <?=!$pager->hasPreviousPage() ? 'disabled' : ''?>">
<a class="page-link" aria-label="<?= lang('Pager.first') ?>" href="<?= $pager->getFirst() ?>"><span aria-hidden="true">«</span></a>
</li>
<?php foreach ($pager->links() as $url) :?>
<li class="page-item pager-item <?=$url['active'] ? 'active' : ''?>"><a class="page-link" href="<?=$url['uri']?>"><?=$url['title']?></a></li>
<?php endforeach ?>
<li class="page-item <?=$pager->hasNext() ? '' : 'disabled'?>">
<a class="page-link" aria-label="Next" href="<?= $pager->getLast() ?>"><span aria-hidden="true">»</span></a>
</li>
</ul>
</nav>
</div>
</div>
<标题>控制器h1> JS h1> div class="one_answers">要实现您想要的,您可以使用CI4方法"isAJAX()">
public function index()
{
// code...
// $data['listMT'] = json_decode($this->material());
// return view('materialKatalog', $data);
// $data['listMT'] = $this->mamat->paginate(50, 'material');
$data['listMT'] = $this->mamat->paginate(50, 'material');
$data['pager'] = $this->mamat->pager;
if ($this->request->isAJAX()) {
// Use View that only phrase tr and td tags
return view('materialKatalog', $data);
} else {
// Full page render
return view('materialKatalog', $data);
}
}
我给你最好的建议是看看数据库库。
标题>