title: Symfony2 - Get ID from route to controller
body: <p>little trouble working something out.  I have a /view-alerts page which displays my data.  For each row of data I provide a delete option</p>
  
  <pre><code>&lt;input type="button" value="Delete" data-url="{{ path('NickAlertBundle_delete') }}" onclick="delete_alert( {{ alert[0].id }} )"/&gt;
  </code></pre>
  
  <p>So when this button is clicked, a javascript function is called.</p>
  
  <pre><code>function delete_alert(id){
      var answer = confirm("Confirm delete");
      if (answer){
          $.ajax({
              type: "POST",
              url: $(this).attr('data-url'),
              data: {row: id},
              success: function(data) {
                  if(data){
                      var splitdata = data.split(":");
                      if(splitdata[0]=="Deleted"){
                          var id = splitdata[1];
                          alert("Your alert has been deleted");
                      }else{
                          alert(data);
                      }
                  }else{
                      alert("Unknown Error!");
                  }
              },
              error:function(){
                  alert("Please try again!");
              }
          });
      }
  </code></pre>
  
  <p>So that calls my delete route, and should pass the id of the data row to be deleted.  My route is currently like so</p>
  
  <pre><code>NickAlertBundle_delete:
      pattern:  /view-alerts
      defaults: { _controller: NickAlertBundle:Alert:delete }
      requirements:
         _method:  POST
  </code></pre>
  
  <p>I have the same url pattern as view-alerts because when they delete an alert from this page, I dont want them redirected to another page.</p>
  
  <p>So now I am trying to access the id in my controller so I can delete the alert.  At the moment I am trying</p>
  
  <pre><code>public function deleteAction(Request $request)
  {
          $id = $request-&gt;get('id');
  
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $alert = $em-&gt;getRepository('NickAlertBundle:AvailabilityAlert')-&gt;find($id);
  
          if (!$alert) {
              throw $this-&gt;createNotFoundException('Alert not found');
          }
  
          $alert-&gt;setIsDeleted(true);
          $alert-&gt;setAlertStatus('Inactive');
          $em-&gt;flush();
  
          return new JsonResponse('Deleted');
  }
  </code></pre>
  
  <p>The error I am currently receiving is</p>
  
  <blockquote>
    <p>The identifier id is missing for a query of
    Nick\AlertBundle\Entity\AvailabilityAlert</p>
  </blockquote>
  
  <p>How can I get the id to my controller with the way I am doing things (through an ajax request?)</p>
  
  <p>Thanks</p>