【发布时间】:2015-07-22 00:53:30
【问题描述】:
我在视图 A 中有一个搜索过滤器,用户可以为研究选择一些值。我想在表格视图的底部显示研究结果,无需重新加载页面。
在视图 A 中,我使用了搜索过滤器。同样的观点,我正在做这个 ajax 调用:
var tab = new Array();
function updateResult(){
$.ajax({
type:"POST",
url:"<?php echo Router::url(array('controller'=>'AController','action'=>'index'));?>",
data : {dataFVariables: $("select[name='filtreVariable\\[\\]']").map(function(){return $(this).val();}).get()},
dataType: 'json',
async:false,
success: function(tab){
..........
// Creating a table with the data in 'tab'
..........
},
error: function (tab) {
alert('error');
}
});
}
在控制器的“索引”操作中,我从数据库中检索了大量数据。使用这些数据,我创建了一个表,但分页在此表上不起作用.. 确实,在我的控制器中,我这样做了:
.............
$this->paginate($query);
// the data send to the ajax call
echo json_encode($query);
结果在我的表格的第一页,但在其他页面中没有任何内容。
提前谢谢你!!
【问题讨论】:
-
查看 this 以及 CakePHP 3.x 的源代码,以获得一个简单的后备安全解决方案(非 JS 用于 SEO 等)。
-
您能否告诉我如何在 cakephp 3 中获取 Ajax 分页示例的代码?
-
还有一个完整的示例和可用的代码。链接的 github repo 是开源的。
-
@mark 我去链接,这是一个非常好的 ajax 分页示例,但我找不到该示例的代码。我下载了项目表单github.com/dereuromark/cakephp-sandbox,但无法在我的本地主机上运行
标签: php jquery ajax cakephp pagination