yii框架ajax分页的使用
的下方写上以下代码
<?php $this->beginBlock("abc"); ?>
$(document).on("click",".pagination a",function(e){
e.preventDefault();
var url=$(this).attr("href");
$.get(url,function(msg){
$("#lists").html(msg);
});
});
<?php $this->endBlock(); $this->registerJs($this->blocks["abc"], View::POS_END); ?>
在上方使用一下类
use yiiwebView;
第二步:在控制器层最后返回数据的时候,加上下面的代码,判断一下是否是ajax提交
if(Yii::$app->request->isAjax)
{
return $this->renderPartial("lists",[
"model" => $model_arr,
"pagination" => $pages,
"name"=>$name,
]);
}
else
{
return $this->render("lists",[
"model" => $model_arr,
"pagination" => $pages,
"name"=>$name,
]);
}
- 上一篇: PHP介绍,总结
- 下一篇:没有了