title: Filter data based on query and return result using Partial view
body: <p>I am trying to filter data based on a query. I am using a partial view to show the filtered data. However, nothing is updated in the partial view. How can I fix this?</p>
  
  <p>Controller class:</p>
  
  <pre><code>public IActionResult Index() {
      IEnumerable&lt;Organisation&gt; organisations = _organisationRepository.GetAll().OrderBy(b =&gt; b.Name).ToList();
  
      if (isAjaxRequest()) {
          string text = Request.Form["text"].ToString();
          return PartialView("_Organisations", _organisationRepository.GetByName(text).ToList());
          }
  
          return View(organisations);
      }
  
  private bool isAjaxRequest() {
          return Request != null &amp;&amp; Request.Headers["X-Requested-With"] == "XMLHttpRequest";
      }
  </code></pre>
  
  <p>Organisation View:</p>
  
  <pre><code>&lt;form asp-controller="Organisation" asp-action="Index"&gt;
  &lt;div class="form-inline"&gt;
      &lt;div class="form-group"&gt;
  
          &lt;label for="text"&gt;Filteren in organisaties&lt;/label&gt;
          &lt;input type="text" name="text" id="text" required pattern="^([0-9]{4}|[a-zA-Z]+)$"&gt;
  
          &lt;label for="selected"&gt;&lt;/label&gt;
          &lt;select name="selected" id="selected" class="form-control"&gt;
              &lt;option value="name"&gt;Naam&lt;/option&gt;
              &lt;option value="postalcode"&gt;Postcode&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
  
      &lt;button type="submit" class="btn btn-default" id="search"&gt;Zoeken&lt;/button&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  
  &lt;div id="partial"&gt;
      @Html.Partial("_Organisations", Model);
  &lt;/div&gt;
  </code></pre>
  
  <p>Partial view:</p>
  
  <pre><code>&lt;table class="table table-striped table-condensed table-bordered"&gt;
  &lt;tr&gt;
      &lt;th&gt;Naam&lt;/th&gt;
      &lt;th&gt;Adres&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
  &lt;/tr&gt;
  
  @foreach (var item in Model) {
      &lt;tr&gt;
          &lt;td&gt;
              @item.Name
          &lt;/td&gt;
          &lt;td&gt;
              @item.Location.ToString()
          &lt;/td&gt;
          &lt;td&gt;
              &lt;a onClick="showForm(this, @item.OrganisationId)" href="#"&gt;Selecteer&lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>
  
  <p></p>
  
  <p>Javascript file:</p>
  
  <pre><code>$("#search").click(function () {
      $.ajax({
      url: "Organisation/Index",
      type: "post",
      data: $("form").serialize(),
      success: function (result) {
          $("#partial").html(result);
          }
      });
  });
  </code></pre>
  
  <p>Any help would be appreciated!</p>