任何人都可以帮助我在cakephp中使用ajax分页与search option.i.e后,点击搜索按钮数据加载类似于输入的数据。我想在cakephp中做到这一点。我正在使用它的当前版本。
提前致谢。
答案 0 :(得分:1)
首先,它非常类似于使用Ajax分页的核心PHP。 在控制器中:
var $components = array('RequestHandler'); //load Requesthandler for ajax
function view_data(){
$this->RequestHandler->isAjax(){ // checking for ajax request
// code goes here
$start = $_POST['start'] ;
$limit = $_POST['limit'] ;
// with conditions also . and the execute query
$table_data = $this->Model->query("SELECT * FROM books limit " . $start. ", ". $limit) ;
// OR any method you want like $this->Model->find('list', 'any'....)
$total_count = $this->Model->find('count', "$your_query") ;
echo json_encode(array( $table_data, $total_count) ; // you can also loop the data ..
}
}
现在在视图中接收数据并循环通过它。另请查看Here的分页div样式。