title: send data from twig to controller using ajax in symfony 3.4
body: <p>i want to  send data from a view (Twig) to controller without refreshing the page so i used ajax , in order to pass data to a specific controller action . 
  this is my ajax code in the twig file :</p>
  
  <pre><code>   &lt;script&gt;     
          var data = {request : $('#content').val()};
  
          $.ajax({
            type: "POST",
            url: "{{ path('AjoutAjax') }}",
            data: data,
            success: function (data, dataType) {
              alert(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
              alert('Error : ' + errorThrown);
            }
          });
  &lt;/script&gt; 
  </code></pre>
  
  <p>this is my twig file : </p>
  
  <pre><code>&lt;div class="column text-lg"&gt;Subtotal: &lt;span class="text-medium" id="content"&gt;
  
  </code></pre>
  
  <p>this is my controller action : </p>
  
  <pre><code>
      public function AjoutAjaxAction(Request $request)
      {
          $data = $request-&gt;request-&gt;get('request');
          echo $data;
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $reservation = $em-&gt;getRepository('techeventBundle:Panier')-&gt;find(11);
          $reservation-&gt;setTotal($data);
          $em-&gt;flush();
          return $this-&gt;render('@reservation/Default/afficherPanier.html.twig');
      }
  </code></pre>
  
  <p>and this is the routing file  </p>
  
  <pre><code>affichage:
      path:     /afficherPanier/{iduser}
      defaults: { _controller: reservationBundle:Default:afficherPanier }
  AjoutAjax:
      path:     /ajoutAjax
      defaults: { _controller: reservationBundle:Default:AjoutAjax }
  </code></pre>
  
  <p>the problem is :</p>
  
  <p>1/ it's not sending data to the controller action because when i tried with the path 'AjoutAjax'  it's not showing the echo '$data' .</p>
  
  <p>2/with any path should i test with 'affichage' or  'AjoutAjax' to know that is working ? 
  '</p>