-1
任何人都可以幫助我如何在cakephp中使用ajax分頁與搜索option.i.e後點擊搜索按鈕數據加載類似於輸入的數據。我想在cakephp中做到這一點。我正在使用它的當前版本。在cakephp的Ajax分頁與搜索選項
在此先感謝。
任何人都可以幫助我如何在cakephp中使用ajax分頁與搜索option.i.e後點擊搜索按鈕數據加載類似於輸入的數據。我想在cakephp中做到這一點。我正在使用它的當前版本。在cakephp的Ajax分頁與搜索選項
在此先感謝。
首先它與使用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樣式。
http://stackoverflow.com/questions/how-to-ask – Dave
可能的重複[簡單的ajax示例與cakephp 2.3.0](http://stackoverflow.com/questions/14768635/simple-ajax-example -with-cakephp的-2-3-0) –