I have the following code which sends an array with the data of my HTML table to the controller to update them in the database so far so good, the problem is that it shows the error: Error: No resource with given URL found, 500 (Internal Server Error) asp.net mvc
I clarify that both functions (ajax and controller) are repeated for each row of my table.
function GuardarF() {
$.ajax({
type: 'POST',
dataType: "json",
url: '/MyController/MyView',
traditional: true,
data: {
array: array
},
success: function (data) {
if (data.rstProceso === "true") {
console.log('Exito: ' + data.rstMensaje);
} else if (data.rstProceso === "false") {
console.log('Algo salió mal ' + data.rstMensaje);
}
},
error: function (jqXHR, status, err){
console.log(jqXHR.responseText);
}
});
}
MyController
[HttpPost]
public ActionResult MyView(int[] array)
{
JsonResult dtaEjecucionTarea = default(JsonResult);
dtaEjecucionTarea = Json(new
{
rstProceso = "false",
MessageGestion = "Error, algo salió mal, intente de nuevo"
});
if (Update_MyView(array))
{
dtaEjecucionTarea = Json(new
{
rstProceso = "true",
MessageGestion = "Cambios guardados con éxito"
});
}
return View(dtaEjecucionTarea);
}
public bool Update_MyView(int[] array)
{
if (array != null)
{
//my code
bd.SaveChanges();
return true;
}
else
{
return false;
}
}
Something similar happened to me, only that it did not load any img or .js file in an asp project in c# when I changed the port of the application, it took a day to find the error, I caught it in web.config, comment the code and it was fixed
For my part, I would recommend that the MyView function return a JSon, with affirmative or negative task execution information, so that the JQuery-Ajax success function obtains that information and processes it, eg: