title: Fill a DropDownList based on the selected value from another DropDownList
body: <p>I was trying to fill a DropDownList based on the value from another DropDownList in MVC .NET Core 2.2.</p>
  
  <pre><code>&lt;div class="form-group row"&gt;
      &lt;label class="col-sm-2 col-form-label"&gt;Type :&lt;/label&gt;
          &lt;div class="col-sm-10"&gt;
              &lt;select asp-for="SelectedType" asp-items="@(new SelectList(Model.TypeList, "TypeName", "TypeDescription"))" class="custom-select custom-select-sm"&gt;
              &lt;/select&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  
  public class Type
  {
      public string TypeName { get; set; }
      public string TypeDescription { get; set; }
  }
  </code></pre>
  
  <p>I'm not familiar with JavaScript or Ajax and I can't figure the example on Google out.</p>
  
  <p>So basically if you select in DropDownList "Type" for example "A", the DropDownList needs to be filled with a list of strings based on "A", when you select "B" the DropDownList needs to be filled with a list of strings based on "B".</p>
  
  <p>Can someone provide me a very easy example?</p>
  
  <p>Something like this?</p>
  
  <pre><code>$(document).ready(function()  
  {  
      $("#ddlEmployee").on("change", function()  
      {  
          $.ajax(  
          {  
              url: '/Home/GetTypesBasedOnValueFromOtherDropDownList' + $(this).attr("value"),  
              type: 'GET',  
              data: "",  
              contentType: 'application/json; charset=utf-8',  
              success: function(data)  
                  {  
                      $("#???").html(data);  
                  },  
              error: function()  
              {  
                  alert("error");  
              }  
          });  
      });  
  }); 
  &lt; /script&gt; 
  </code></pre>