title: Ajax with twig, how it works?
body: <p>From my controller I send several parameters in my html.twig, then I want to make a AJAX request like this one : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{% if text is defined %}
      var text = {{ text }};
      var sender = {{ sender }};
      var date_send = {{ date_send|date('d/m/Y') }};
      var mess_type = {{ mess_type }};
      var to = {{ to }};
  
      $.post('send.php', {text:text, sender:sender, date_send:date_send, mess_type:mess_type, to:to}, function(data)
      {
          $('#Map').text(data);
      });
  {% endif %}</code></pre>
  </div>
  </div>
  </p>
  
  <p>SO when I do that, I have this error : </p>
  
  <pre><code>POST http://localhost:8000/send.php 500 (Internal Server Error)
  </code></pre>
  
  <p>My send.php is where my html.twig is. I just have an echo "hi" in my <code>send.php</code> for testing, but it does not display anything.</p>
  
  <p>I also tried to put a send function in my controller :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/**
  * @Route("/send.php", name="send")
  */
  public function send(Request $request) {
      dump("hi");
      echo "send";
      return null;
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>And I replace <code>'send.php'</code> by <code>{{path('send.php')}}</code> inside my <code>html.twig</code> (inside <code>$.post()</code>).
  I know I can't return null, but It does not display my dump. And I have this error : </p>
  
  <pre><code>An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "/send" as such route does not exist.")
  </code></pre>
  
  <p>And it does not get me to <code>/send.php</code>. I don't know what can I miss, I didn't find any solution on google. Thank for your help.</p>