I have a getJSON that loads a DDL from another. But the first time its loaded, it does it well. When I make a submit on the page, at the console I get error 404 on the getJSON and when I double click it, it sends me the getJSON but without the controller Visual Explanation:
Function:
function showPuestoEdit(val, index) {
$.getJSON("GetPuestosCargaJSON" + "?value=" + val, function (result) {
// Cleans the DDL first
$("#ddlPuesto").empty();
var data = result.data;
for (var i = 0; i < data.length; i++) {
$("#ddlPuesto").append("<option value=" + data[i].id_puesto + ">" + data[i].nombre + "</option>")
}
// This is in order to set the second ddl in the correct position
$("#ddlPuesto").val(index);
}); }
My CONTROLLER [Usuario]:
public JsonResult GetPuestosCargaJSON(int? value)
{
// Carga los puestos dependiendo del departamento
List<Puesto> list = repo.GetReaderFromStringToList<Puesto>("SOME SELECT * FROM QUERY HERE where some_id = " + value);
return Json(new { data = list }, JsonRequestBehavior.AllowGet);
}
The first request in the console:
http://localhost:10994/Usuario/GetMunicipiosCargaJSON?value=17
But when I submit some info and I want to try it again the request is :
http://localhost:10994/GetMunicipiosCargaJSON?value=17
In the path before the Action the Controller disappears, so error 404
Problem solved: On the submit I had:
return RedirectToAction("Index");
and now:
return new RedirectResult("Index");