return Response::create($this->fetch(), 'html')->code(200);
if($this->request->isAjax()){
$this->assign('abc','变量输出');
//tp5可以直接return $this->fetch();用ajax接收数据
return Response::create($this->fetch(), 'html')->code(200);//code(200)可省,默认是200,这里是用于jquery easyui
}
后端:
$str 为 $list->render()
function ajax_paginer($str){
return str_replace("href",'href="javascript:" data-href',$str);
}
前端:
<div class="ajax-list"></div> ajax请求返回面中分页:<div class="page-bootstrap">{$list->render() ?= ajax_paginer($list->render())}</div>
$(function () { $('.ajax-list').show(function () { var url = $(this).data('href'); url = url || location.href; $.xget(url,{},function (ret) { $('.ajax-list').html(ret); }); }); $(document).on('click','.ajax-list .page-bootstrap a',function () { var url = $(this).data('href'); if(url){ $.xget(url,{},function (ret) { $('.ajax-list').html(ret); }); } }); });