title: How to reload captcha on form submit via Ajax?
body: <p>I am submitting forms using Ajax. I am using captcha on my form and first time it is working perfect when I submit form without any validation error. Sometimes servers returns some validation errors and does not submit form. At this point I need to refresh the captcha image without reloading whole page. </p>
  
  <p><strong>Captcha Code in Zend Form:</strong></p>
  
  <pre><code>$captcha= new Zend_Form_Element_Captcha('captcha', array(
                  'id'=&gt;'captcha',
                  'title'=&gt;'Security Check.',
                  'captcha'  =&gt; array(
                  'captcha'  =&gt; 'Image',
                  'required' =&gt; true,
                  'font'     =&gt; '../public/fonts/ARIALN.TTF',
                  'wordlen'  =&gt; '6',
                  'width'    =&gt; '200',
                  'height'   =&gt; '50',
                  'imgdir'   =&gt; '../public/images/captcha/',
                  'imgurl'   =&gt; '/images/captcha/'
                  )));
  </code></pre>
  
  <p><strong>jQuery for form submission:</strong></p>
  
  <pre><code>jQuery('form.AjaxForm').submit( function() {
  
      $.ajax({
          url     : $(this).attr('action'),
          type    : $(this).attr('method'),
          dataType: 'json',
          data    : $(this).serialize(),
          success : function( data ) {
                        // reload captcha here
                        alert('Success'); 
                    },
          error   : function( xhr, err ) {
                        // reload captcha here
                        alert('Error');
                  }
      });
  
      return false;
  }); 
  </code></pre>
  
  <p>How to reload captcha on form submit  ?</p>
  
  <p>Thanks</p>