title: Ajax request for asp.net mvc controller returning 500 - internal server error
body: <p>I have these two <code>select</code>s on a view:</p>
  
  <pre><code>&lt;select class="input-sm form-control input-s-sm inline" onchange="carregarCidades()" id="comboEstado"&gt;
      ...
  &lt;/select&gt;
  
  &lt;select class="input-sm form-control input-s-sm inline" id="comboCidade"&gt;
     ...
  &lt;/select&gt;
  </code></pre>
  
  <p>The first represents a State, and when I select it I want to execute the <code>carregarCidades</code> function to load the cities of that stat and them load them in the other select. Here is the function:</p>
  
  <pre><code>function carregarCidades() {
      var url = "@Url.Action("CarregarCidades", "Usuario")";
  
      var estado = $("#comboEstado").find(":selected").text();
  
      $.get(url, { pEstado: estado }, function (cidades) {
          $("#comboCidade").html(""); // clear before appending new list 
          $.each(cidade, function (i, cidade) {
              $("#comboCidade").append(
                  $('&lt;option&gt;&lt;/option&gt;').val(cidade.id_cidade).html(cidade.cidade));
          });
      });
  }
  </code></pre>
  
  <p>Now, here is the CarregarCidades action in the UsuarioController:</p>
  
  <pre><code>public ActionResult CarregarCidades(string pEstado)
  {
      string cCidades = oVFP.BuscaCidade(pEstado);
  
      DataSet dsC = new DataSet();
      dsC.ReadXml(new StringReader(cCidades));
  
      JsonResult result = Json(dsC.Tables["curretorno"]);
      return result;
  }
  </code></pre>
  
  <p>I'm debugging the action and apparently everything is ok:</p>
  
  <p><a href="https://i.stack.imgur.com/eEB4q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eEB4q.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/Xotf5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xotf5.png" alt="enter image description here"></a></p>
  
  <p>But, after the Action returns the Json result, the callback funcion is not called on the jquery code and I got a 500 internal server error in my console.</p>