I am trying to validate the login of my application with a POST
method, but the problem is that I do not know how to redirect once I get the response from the server.
$.ajax({
type: "POST",
url: '@Url.Action("IniciarSesion", "Inicio")',
content: "application/json; charset=utf-8",
dataType: "json",
data: { "Usuario": _usuario, "Clave": _clave },
success: function (respuesta) {
if (respuesta.model == '1') {
//aqui debería redireccionar de alguna manera
} else if (respuesta.model == '0')
{
Alert.render('El usuario ingresado no está registrado');
} else if (respuesta.model == '2') {
Alert.render('La clave ingresada es incorrecta');
}
},
error: function (xhr, textStatus, errorThrown) {
Alert.render('Error: No se pudo cargar método "Validar Usuario"');
}
});
I work it this way, since I need to indicate information of income errors. That's why I do not use the submit.