title: How can i pass data from my Ajax function to a HTML model in a partial view?
body: <p>I want to use an Ajax function to change the HTML model in a partial view. The function in the MVC controller returns the correct value (List). But how can i pass this data (result) from the Ajax function to a partial view (_locationListPartial) ? This is what I have so far. </p>
  
  <p><strong>Ajax function</strong></p>
  
  <pre><code>function PassLocationList(id) {
      $.ajax({
          type: 'POST',
          url: 'Home/GetLocations',
          data: { 'id': id },
          success: function (result) {
  
          *** WHAT CODE DO I NEED HERE (Passing to partial view) ***
  
          }
      });
  }
  </code></pre>
  
  <p><strong>_locationListPartial</strong></p>
  
  <pre><code>&lt;div class="sidebar_list"&gt;
  
          *** WHAT CODE DO I NEED HERE (@Model list)? ***
  
          @if (list == null || list.Count() == 0)
          {
              &lt;div&gt;Geen items gevonden!&lt;/div&gt;
          }
          else
          {
              @foreach (var item in list)
              {
                  &lt;partial name="../Shared/_LocationItemPartial.cshtml" model="@item" /&gt;
              }
          }
      &lt;/div&gt;
  </code></pre>
  
  <p><strong>Controller function</strong></p>
  
  <pre><code>[HttpPost]
      public List&lt;Location&gt; GetLocations(int id)
      {
          List&lt;Location&gt; LocationList = _context.Locations.Where(p =&gt; p.CategoryId.Equals(id)).ToList();
          return LocationList;
      }
  </code></pre>