1
I am deleting with Ajax and returning a Json. How do I open a different view? Follow the code, put the url no longer works:
View
$.ajax({
url: '@Url.Action("ExcluirPedidoCompra")', // to get the right path to controller from TableRoutes of Asp.Net MVC
dataType: "json", //to work with json format
type: "POST", //to do a post request
contentType: 'application/json; charset=utf-8', //define a contentType of your request
cache: false, //avoid caching results
data: "{\"id\" : " + id + "}", // here you can pass arguments to your request if you need
success: function (data) {
if (data > 0) {
url: '/PedidoCompraConsultar/Index'
}
},
error: function (xhr) {
alert("Erro! Ocorreu um erro ao excluir, Favor Entrar em Contato com O Suporte.");
}
});
controller code
public ActionResult ExcluirPedidoCompra(int id)
{
var resultado = 1;
return Json(resultado);
}
I have tried it all. If anyone can help me I want to go to "Pedidocompraconsultarcontroller - Index".
testou, url: '@Url.Action("Pedidocompraconsultar")' ?
– HudsonPH