Im new to ZF. Im struggling to implement a AJAX form submission using Jquery, can somebody point me to a good tutorial explaining the same (something which works on ZF 1.10.+)
Thanks in advance!
I will explain how I have implemented Ajax submission using jQuery in Zend Framework. You have to build your form like the following.
$form->setAttrib('id','div_form');
$form->addElement('submit', 'submit', array(
'label' => 'Ajax Submit',
'onclick' => "$('#div_form').load('" . "/ajax/submit" . "', $('#div_form').serializeArray() ); return false;"
));
Add the submit like the one shown above.
return false;
cancels actual submission of form.
In your AjaxController.php,
public function submitAction() {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(TRUE);
//Get your form data from the params
Zend_Debug::dump($this->_getAllParams());
//Process data using your model and return appropriate messages.
echo "Your form is submitted";
}
Try the above and let me know if you have any issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With