title: Symfony2 send form ajax
body: <p>I'm trying to submit a form via ajax to update a field of an entity, but do not know how to retrieve the data from the controller:</p>
  
  <pre><code>&lt;form class="ajax" action="{{ path('ajax_setSocial') }}" method="post" {{ form_enctype(form) }}&gt;
    &lt;div class="editor"&gt;
          {{ form_errors(form) }}
          &lt;div class="editLabel pls"&gt;{{ form_label(form.ragSocial) }}&lt;/div&gt;
          &lt;div class="editField"&gt; 
              &lt;div class="ptm"&gt;
                  {{ form_widget(form.ragSocial) }} {{ form_errors(form.ragSocial) }}
              &lt;/div&gt;     
              {{ form_rest(form) }}
              &lt;div class="mtm"&gt;
                  &lt;button class="btn btn-primary disabled save" type="submit"&gt;Save&lt;/button&gt;
                  &lt;button class="btn ann"&gt;Close&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>  var url = Routing.generate('ajax_setSociale');
          var Data = $('form.ajax').serialize();
          $.post(url, 
              Data
              , function(results){
                  if(results.success == true) {
                      $(this).parents('ajaxContent').remove();
                      $(this).parents('.openPanel').removeClass('openPanel');
                  } else {
                      alert('False'); //test
                  }
          });
  </code></pre>
  
  <p>controller (ajax_setSocial route)</p>
  
  <pre><code>public function setSocialeAction(Request $request)
  {
        $em = $this-&gt;getDoctrine()-&gt;getManager();
        // $id = $request-&gt;get('form'); ???
      $entity = $em-&gt;getRepository('MyBusinessBundle:Anagrafic')-&gt;find($id);
  
      if (!$entity) {
          throw $this-&gt;createNotFoundException('Unable to find Anagrafic entity.');
      }
  
      $form = $this-&gt;createFormBuilder($entity)
         -&gt;add('ragSocial', 'text', array('label' =&gt; 'Social'))
         -&gt;add('id', 'hidden')
          -&gt;getForm();
      $form-&gt;bind($request);
  
      if ($form-&gt;isValid()) {
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
          $output = array();
          $response = new Response();
          $output[] = array('success' =&gt; true);
          $response-&gt;headers-&gt;set('Content-Type', 'application/json');
          $response-&gt;setContent(json_encode($output));
          return $response;
      }
  </code></pre>
  
  <p>As recovery values ​​and then pass the id to create the query and the other values ​​to update the entity?
  And if the fields do not pass validation, how do I pass the error?</p>