我尝试使用 JsHelper 使用 CakePHP 创建 Ajax 搜索。Ajax 请求触发但它从不返回值:
搜索表格(find_entries.ctp):
<?php echo $this->Form->create('Entry');?>
<?php echo $this->Form->input('title', array('div' => false, 'empty', 'label' => false, 'placeholder' => 'Search'));?>
<?php echo $this->Js->submit('Upload', array(
'before'=>$this->Js->get('#checking')->effect('fadeIn'),
'success'=>$this->Js->get('#checking')->effect('fadeOut'),
'update'=>'#choose_options')
)
;?>
<?php echo $this->Form->end();?>
控制器:
public function find_entries(){
if(!empty($this->request->data)){
$entries = $this->Entry->find('all', array('conditions' => array('Entry.title' => $this->request->data['Entry']['title);
$this->set('entries', $entries);
if($this->RequestHandler->isAjax()){
$this->render('entries', 'ajax');
}
}
}
部分渲染 (entry.ctp)
<div id="entries">
<?php foreach ($entries as $entry) :?>
<?php echo $entry['Entry']['title']; ?>
<?php endforeach ;?>
这里出了什么问题?谢谢!