title: Grails JQuery Ajax Form Validation
body: <p>I have a modal dialog where I load a form from a gsp and I am struggling to find the right solution for an ajax based form with JSON validation incl. success message like a flash scope message:</p>
  
  <pre><code>$('#calendar_form').live('click', function () {
          $.modal({
              ajax: './form'
              , title: '${message(code:'calendar.main.addAppointment')}'
              , overlayClose: true
          });
      });
  </code></pre>
  
  <p>In that form I have the following JS:</p>
  
  <pre><code>$(document).ready(function() {
      $('#form1').submit(function() {
  
          $.ajax({
              type: 'POST',
              url: '${createLink(action:'post')}',
              data: $("#form1").serialize(),
              success: function(result) {
                  alert(result);
              }
          });
      });
  });
  </code></pre>
  
  <p>I am returning a JSON response if its successful and when an error occurs and I need Ajax otherwise my modal dialog is disapearing due to the new request.</p>
  
  <p>So here are my questions:</p>
  
  <ul>
  <li>How do I react on failures which happen during my validation in my controller?</li>
  <li>Which error http codes do I need to use for validation errors in my controller?</li>
  <li>How do I update the specific fields with error messages in my form?</li>
  <li>How do I update the flash part of my page to render the success msg?</li>
  <li>How is it possible to update other parts of the page after success?</li>
  </ul>
  
  <p>Thank you!</p>