title: How can I get post parameters on ajax request in Symfony 3
body: <p>I have an ajax request working fine. My problem is I do not really know how to use correctly my controller to get the datas in the format I would like. </p>
  
  <p>I would like to use this kind of method:</p>
  
  <pre><code>$request-&gt;request-&gt;get('pseudo'); // will return "bob"
  </code></pre>
  
  <p>Here is my controller code:</p>
  
  <pre><code>public function mainPlayAction(Request $request)
  {
  
      if ($request-&gt;isXmlHttpRequest())
      {
          $allContent = $request-&gt;getContent(); // will return a string with this format "selectedBalls=34&amp;selectedStars=11"
  
          $selectedBalls = $request-&gt;request-&gt;get('selectedBalls'); // will return null
  
          $selectedstars= $request-&gt;request-&gt;get('selectedStars'); // will return null
  
          $all = $request-&gt;request-&gt;all(); // will return Array[0]
  
          $response = [
              'allContent' =&gt; $allContent,
              'selectedballs' =&gt; $selectedBalls,
              'selectedStars' =&gt; $selectedStars,
              'all' =&gt; $all,                
              'success' =&gt; true,
              "status" =&gt; 100
          ];
  
          return $this-&gt;json($response);
      }
  }
  </code></pre>
  
  <p>Here is my ajax code</p>
  
  <pre><code>$.ajax({
      url: url,
      dataType: "json",
      contentType: "application/json; charset=utf-8",
      type: "POST",
      data: {
          'selectedballs': selectedBalls,
          'selectedStars': selectedStars,
          'countGames': countGames
      },
      success: function (response) {
          window.console.log(response);
      },
  })
  </code></pre>