title: Ajax with Symfony 4
body: <p>I'm trying to connect Ajax with Symfony 4. I need to send some data to my Controller. </p>
  
  <p>JavaScript: </p>
  
  <pre><code>$(function() {
      $('#sortable').sortable({
          axis: 'y',
          opacity: 0.7,
          update: function(event, ui) {
              var list_sortable = $(this).sortable('toArray').toString();
  
              $.ajax({
                  url: 'path(app_bundle_route)',
                  type: 'POST',
                  dataType: 'json',
                  data: {list_order:list_sortable},
                  success: function(data) {
                      console.log("xyxy");
                  }
              });
          }
      });
  });
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>/**
    * @Route("/admin/pages/reorder", name="admin_pages_reorder")
    * @return \Symfony\Component\HttpFoundation\Response
   */
   public function reorder(Request $request):Response
   {
     var_dump($request-&gt;getContent());
     die;
   }
  </code></pre>
  
  <p>I'm getting only 404 on this:</p>
  
  <p><a href="http://localhost:8000/admin/path(admin_pages_reorder)" rel="nofollow noreferrer">http://localhost:8000/admin/path(admin_pages_reorder)</a>.</p>
  
  <p>Not even adding braces {{ path(...) }} helped.</p>
  
  <p>I've solved that right after placing this question. </p>
  
  <p><strong>You have to place {{ path(route name) }} right into .twig, not external .js file</strong></p>