title: How can I send JSON response in symfony2 controller
body: <p>I am using <code>jQuery</code> to edit my form which is built in <code>Symfony</code>.</p>
  
  <p>I am showing the form in <code>jQuery</code> dialog and then submitting it.</p>
  
  <p>Data is entering correctly in database.</p>
  
  <p>But I don't know whether I need to send some <code>JSON</code> back to <code>jQuery</code>. Actually I am bit confused with <code>JSON</code> thing.</p>
  
  <p>Suppose I have added a row in my table with ``jQuery and when I submit the form then after data is submitted I want to send back those row data so that I can dynamically add the table row to show the data added.</p>
  
  <p>I am confused how can get that data back.</p>
  
  <p>This is my current code:</p>
  
  <pre><code>$editForm = $this-&gt;createForm(new StepsType(), $entity);
  
  $request = $this-&gt;getRequest();
  
  $editForm-&gt;bindRequest($request);
  
  if ($editForm-&gt;isValid()) {
      $em-&gt;persist($entity);
      $em-&gt;flush();
  
      return $this-&gt;render('::success.html.twig');               
  }
  </code></pre>
  
  <p>This is just the template with success message.</p>