title: Calling partial view through AJAX in Asp.net MVC 5
body: <p>I'm using the following code to call a partial view:</p>
  
  <pre><code>$('#btnGetMilestones').click(function () {
  $.ajax({
      url: "GetMilestones",
      type: "get",
      success: function (result) {
          $('#milestonesContainer').html(result);
      },
      error: function (xhr, status, error) {
          var msg = "Response failed with status: " + status + "&lt;/br&gt;"
          + " Error: " + error;
          $('#milestonesContainer').html(msg);
      },
      complete: function (xhr, status) {
          var doneMsg = "Operation complete with status: " + status;
          alert(doneMsg);
      }
  });
  </code></pre>
  
  <p>});</p>
  
  <p>for this ActionResult:</p>
  
  <pre><code>public PartialViewResult GetMilestones()
      {
          return PartialView("_GetMilestones");
      }
  </code></pre>
  
  <p>The partial view has the milestones for a project (milestones and project are models). When I call the partial view like this: </p>
  
  <pre><code>&lt;div id="milestonesContainer"&gt;
      @Html.Partial("_GetMilestones")
  &lt;/div&gt;
  </code></pre>
  
  <p>it works fine, it gets all the milestones for the project.
  But when I try to call the partial view via ajax, the error gets called: Response failed with status: error</p>
  
  <p>Error: Bad Request</p>
  
  <p>I'm in the details view of a projects so the url is like this <a href="http://localhost:55623/Projects/Details/2002" rel="nofollow">http://localhost:55623/Projects/Details/2002</a></p>
  
  <p>I'm new in ajax and javascript, so please if possible, explain me like you do to a beginner.</p>
  
  <p>UPDATE:</p>
  
  <p>After getting some answer and playing around to find a solution, I understand why the error appears.
  I'm inside the details view, so the url is like this: <a href="http://localhost:55623/Projects/Details/2002" rel="nofollow">http://localhost:55623/Projects/Details/2002</a> see there is an ID parameter.
  When I make the ajax call, the url is like this <a href="http://localhost:55623/Projects/Details" rel="nofollow">http://localhost:55623/Projects/Details</a> without the id parameter. So in return I get a 400 error code</p>