开发者

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

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

Im new to ZF. Im str开发者_如何学编程uggling 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜