0
這裏ajax搜索工作正常,但問題是相同的數據顯示兩次,因爲我給了分頁限制2.如果我使它3,同樣的結果顯示3倍。CakePHP Ajax搜索:顯示相同的數據兩次分頁
這裏是我的index.ctp
$("#search").keyup(function() {
var value=$('#search').val();
$.get("<?php echo Router::url(array('controller'=>'userTypes','action'=>'search'));?>",{search:value},function(data){
$('.search_data').html(data);
});
})
這裏是我的搜索行動
public function search()
{
$search=$_GET['search'];
$request=$this->UserType->find('all', array(
'conditions' => array('UserType.name LIKE' => "%$search%")
));
$this->set('usertype',$request);
}
這裏是search.ctp
<?php foreach($usertype as $usertypes) { ?>
<tr>
<td><?php echo $usertypes['UserType']['id']; ?></td>
<td><?php echo $usertypes['UserType']['name']; ?></td>
<td><?php echo $usertypes['UserType']['description']; ?></td>
</tr>
<?php } ?>
分頁限制在AppController的
parent::beforeFilter();
$this->Paginator->settings = array(
'limit'=>2
);
結果正顯示出我這個樣子
五月人幫助我解決呢?