Redirection with Ajax in ASP.NET MVC

0

I'm using Ajax to save the form data. The problem is that after saving the data they can not redirect to the "Action Index" where customers are listed registered, since the request was made in Ajax. I thought of creating a PartialView for this and rendering it with jQuery, but it would be redundant because there is already a View for this, which is the home of the system, as he had said. Are there any other alternatives to this?

    
asked by anonymous 01.12.2016 / 14:28

1 answer

2

Do the redirect on ajax success:

    $.ajax({
        url: minhaurl,
        data: $("#meuform").serialize(),
        type: 'post',
        success: function (data) {
                window.location.href = "@Url.Action("Index", "Home")";

        }
    });

This ensures that you only send in case you receive a 200 from the server.

    
01.12.2016 / 14:57