Estou fazendo um exclusão com Ajax e retornando um JSon. Como eu faço para abrir uma view diferente? Segue o código, coloquei o url mais não funciona:
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.");
}
});
código do controller
public ActionResult ExcluirPedidoCompra(int id)
{
var resultado = 1;
return Json(resultado);
}
Já testei de todas as forma. Se alguém puder me ajudar quero ir para "PedidoCompraConsultarController - Index".