【发布时间】:2019-08-03 05:25:25
【问题描述】:
我有一个从另一个加载 DDL 的 getJSON。 但是第一次加载时,它做得很好。当我在页面上提交时,在控制台上我在 getJSON 上收到错误 404,当我双击它时,它会向我发送 getJSON 但没有控制器 视觉解释:
功能:
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
在Action之前的路径中Controller消失了,所以报错404
【问题讨论】:
标签: c# json web model-view-controller getjson