Tag: cakephp 2.0

cakephp 2.3 ajax表单提交

我正在尝试创建一个简单的表单,使用ajax将数据提交到数据库。 这是我的看法 Html->script(‘jquery’, FALSE); ?> Html->script(‘validation’, FALSE); ?> Contact Us Form->create(); echo $this->Form->input(‘name’, array(‘id’=>’name’)); echo $this->Form->input(’email’, array(‘id’=>’email’)); echo $this->Form->input(‘message’, array(‘id’=>’message’)); echo $this->Js->submit(‘Send’, array( ‘before’=>$this->Js->get(‘#sending’)->effect(‘fadeIn’), ‘success’=>$this->Js->get(‘#sending’)->effect(‘fadeOut’), ‘update’=>’#success’ )); echo $this->Form->end(); ?> Sending… 调节器 class MessagesController extends AppController{ public $helpers = array(‘Js’); public $components = array(‘RequestHandler’); public function index(){ if(!empty($this->data)){ if($this->Message->save($this->data)){ if($this->request->isAjax()){ $this->render(‘success’,’ajax’); }else{ $this->Session->setFlash(‘Message sent’); $this->redirect(array(‘action’=>’index’)); […]