title: Laravel passing data using ajax to controller
body: <p>How do I pass the id from this ajax call to the TestController getAjax() function? When I do the call the url is testUrl?id=1 </p>
  
  <pre><code>Route::get('testUrl', 'TestController@getAjax');
  
  &lt;script&gt;
      $(function(){
         $('#button').click(function() {
              $.ajax({
                  url: 'testUrl',
                  type: 'GET',
                  data: { id: 1 },
                  success: function(response)
                  {
                      $('#something').html(response);
                  }
              });
         });
      });    
  &lt;/script&gt;
  </code></pre>
  
  <p>TestController.php</p>
  
  <pre><code>public function getAjax()
  {
      $id = $_POST['id'];
      $test = new TestModel();
      $result = $test-&gt;getData($id);
  
      foreach($result as $row)
      {
          $html =
                '&lt;tr&gt;
                   &lt;td&gt;' . $row-&gt;name . '&lt;/td&gt;' .
                   '&lt;td&gt;' . $row-&gt;address . '&lt;/td&gt;' .
                   '&lt;td&gt;' . $row-&gt;age . '&lt;/td&gt;' .
                '&lt;/tr&gt;';
      }
      return $html;
  }
  </code></pre>