1
我嘗試使用JsHelper創建一個使用CakePHP進行Ajax搜索。 Ajax請求觸發,但它永遠不會返回值:CakePHP 2.1 + AJAX搜索/ JsHelper
搜索表單(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');
}
}
}
局部渲染(entries.ctp)
<div id="entries">
<?php foreach ($entries as $entry) :?>
<?php echo $entry['Entry']['title']; ?>
<?php endforeach ;?>
這裏出了什麼問題?謝謝!
任何錯誤嗎? –