title: Onchange function is not working using mvc?
body: <p>In edit registration form country drop down list is loaded from the database, but it does not enable state drop down list onchange function is not working.</p>
  
  <pre><code>@Html.DropDownList("CountryEdit", null, Model.CountryName, new { @class = "select2-arrow" }) 
  </code></pre>
  
  <p>State Bind:</p>
  
  <pre><code>&lt;select id="state" class="select2-arrow"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>Onchange:State Bind</p>
  
  <pre><code>$(document).ready(function () {
              $("#CountryEdit").on('change', function () {
                  var id = $(this).val();
                  $("#state").empty();
  
                  $.ajax({
                      type: 'POST',
                      url: '@Url.Action("StateEdit_Bind")',
                      dataType: 'json',
                      data: { CountryID: id },
                      success: function (subcategories) {
                          $.each(subcategories, function (i, subcategory) {
                              $("#state").append('&lt;option value="' + subcategory.Value + '"&gt;' + subcategory.Text + '&lt;/option&gt;');
                          });
                      },
                      error: function (ex) {
                          alert('Failed to retrieve Sub Categories : ' + ex);
                      }
                  });
                  return false;
              })
          });
  </code></pre>
  
  <p>Controller Country Bind:</p>
  
  <pre><code>public void CountryEdit_Bind()
          {
              DataSet ds = dblayer.Get_Country();
              List&lt;SelectListItem&gt; coutrylist = new List&lt;SelectListItem&gt;();
              foreach (DataRow dr in ds.Tables[0].Rows)
              {
                  coutrylist.Add(new SelectListItem { Text = dr["CountryName"].ToString(), Value = dr["CountryID"].ToString() });
              }
              ViewBag.CountryEdit = coutrylist;
          }
  </code></pre>
  
  <p>State Bind:</p>
  
  <pre><code>public JsonResult StateEdit_Bind(string CountryID)
          {
              DataSet ds = dblayer.Get_State(CountryID);
              List&lt;SelectListItem&gt; statelist = new List&lt;SelectListItem&gt;();
              foreach (DataRow dr in ds.Tables[0].Rows)
              {
                  statelist.Add(new SelectListItem { Text = dr["StateName"].ToString(), Value = dr["StateID"].ToString() });
              }
              return Json(statelist, JsonRequestBehavior.AllowGet);
          }
  </code></pre>