我有一个getJSON从另一个加载DDL。但它第一次加载,它做得很好。当我在页面上进行提交时,在控制台上我在getJSON上收到错误404,当我双击它时,它会向我发送getJSON但没有控制器Visual Description:
功能:
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);
}); }
我的控制器[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);
}
控制台中的第一个请求:
http://localhost:10994/Usuario/GetMunicipiosCargaJSON?value=17
但是当我提交一些信息并且我想再试一次时,请求是:
http://localhost:10994/GetMunicipiosCargaJSON?value=17
在操作之前的路径中,控制器消失,因此错误404
问题解决了:在我提交的提交中:
return RedirectToAction("Index");
现在:
return new RedirectResult("Index");