title: Zend 1.12 + Ajax - Submit form
body: <p>After user clicks on submit form, I need to call Zend validation of that form without refreshing whole page. I also use zend_Layout in my website. I have seen a lot of tutorials here, but still cant make it working.</p>
  
  <p>Index Controller:</p>
  
  <pre><code>class IndexController extends Zend_Controller_Action {
  
      public function init() {
  
      }
  
      public function indexAction() {
  $this-&gt;view-&gt;static_data = "eg. ABCDEFG"; 
  
          $this-&gt;view-&gt;form = new Application_Form_Test();
      }
      public function ajaxAction() {
          // probably some code to hande ajax 
      }
  }
  </code></pre>
  
  <p>View for index/index:</p>
  
  <pre><code>...
  &lt;?php 
  echo date('m/d/Y h:i:s a', time());
  echo $this-&gt;static_data; 
  ?&gt;
  
  &lt;hr /&gt;
  &lt;?php echo $this-&gt;form ?&gt;
  ...
  </code></pre>
  
  <p>Form:</p>
  
  <pre><code>class Application_Form_Test extends Zend_Form
  {
      public function init()
      {
          $this-&gt;setMethod('post');
          $this-&gt;setAttrib('class', 'form1');
  
          $this-&gt;addElement('text', 'email', array(
              'label'      =&gt; 'Your email address:',
              'required'   =&gt; true,
              'filters'    =&gt; array('StringTrim'),
              'validators' =&gt; array(
                  'EmailAddress',
              )
          ));
  
          $this-&gt;addElement('text', 'name', array(
              'label'      =&gt; 'Your name:',
              'required'   =&gt; true,
              'validators' =&gt; array(
                  array('validator' =&gt; 'StringLength', 'options' =&gt; array(3, 20))
                  )
          ));
  
          // Add the submit button
          $this-&gt;addElement('submit', 'submit', array(
              'ignore'   =&gt; true,
              'label'    =&gt; 'Send',
          ));
  
          // And finally add some CSRF protection
          $this-&gt;addElement('hash', 'csrf', array(
              'ignore' =&gt; true,
          ));
      }
  }
  </code></pre>
  
  <p>So how can i validate form without refreshing rest of that page and see Zend Error Messages in case that form is not valid.</p>