Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want some simple AJAX implementation tutorial using Jquery + Zend Framework [closed]

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!

like image 876
Vikram Avatar asked Mar 08 '11 12:03

Vikram


1 Answers

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.

like image 111
Lenin Raj Rajasekaran Avatar answered Oct 20 '22 20:10

Lenin Raj Rajasekaran