I have two selecton view:
<select class="input-sm form-control input-s-sm inline" onchange="carregarCidades()" id="comboEstado">
...
</select>
<select class="input-sm form-control input-s-sm inline" id="comboCidade">
...
</select>
The first represents the state, and when I select it, I want to execute a function carregarCidadesto load the cities of this stat, and they load them into another select. Here is the function:
function carregarCidades() {
var url = "@Url.Action("CarregarCidades", "Usuario")";
var estado = $("#comboEstado").find(":selected").text();
$.get(url, { pEstado: estado }, function (cidades) {
$("#comboCidade").html("");
$.each(cidade, function (i, cidade) {
$("#comboCidade").append(
$('<option></option>').val(cidade.id_cidade).html(cidade.cidade));
});
});
}
Now, here is the CarregarCidades action in the UsuarioController:
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;
}
I am debugging the action and, apparently, everything is in order:

But after Action returns the Json result, the callback function is not called in jQuery code, and I got 500 internal server errors in my console.
source
share