js代码
$(".pagination a").on('click',function(){
$.post($(this).attr('href'),function(data){
console.log(data);
})
return false;
})
控制器代码
public function actionIndex() {
$model = new Dish();
$where['status'] = 1;
$info = $model->getPageList($where, 10, 'dishid desc');
if(Yii::$app->request->isAjax){
return $this->render('more',[
'list' => $info['list'],
]);
}else{
return $this->render('index',[
'list' => $info['list'],
'page' => $info['page'],
]);
}
}
在运行的时候出现400 错误 在控制器内应该怎么写啊!
服务器端没接收到csrf
可以禁用csrf validation (不推荐)
如果你没有使用
yii.js
的话,就需要你自己来传了