How to do AJAX without refreshing using paginat, the built-in paging method of TP5? I don’t need to write the page number code myself. Does anyone recommend an article with examples? This is a small exercise left by the teacher in the last chapter of TP5.1. I have no idea. Or does it mean that using the built-in paginate can't do it without refreshing?
凡人2019-08-04 15:51:26
No refresh is successful, but the screen will be repeated. Except for the refreshed page, everything else is repeated. . . . Has anyone encountered this problem?
AJAX code part
$(function () {
//Bind all the following a elements "click" to the element with the id of list. "Event
$("#page").on("click",".pagination a",function() { //Get the href of the a tag, which is the url, and send an ajax request
$.get (THIS) .ATTR ('HREF'), Function (html) {
// Back data output to the element of ID to ID,
$ ('#List'). html (html);
; ##Refreshed page in HTML
{include file="index:paginat1" /}
##PHP background. . .
public function paginat1()
{
$artId=Session::get('art_id');
$list=Db::table('zh_user_comments')
- ('status',1)
->where('article_id',$artId)
->order('create_time','desc')
. ;render();
$this->assign('list',$list);
$this->assign('page',$page);
// Front-end ajax paging, If it is an ajax request, it will enter this range, and the following code will not be executed
if(Request::isAjax()){
return $this->fetch('paginat1');
}
$this->assign('list',$list);
$this->assign('page',$page);
return $this->fetch('paginat1 ');
}
Cannot load automatically and use AJAX to call the background method. This method must be called in the background when entering the parent page