Redirecting after Ajax post

success: function(response){
    window.location.href = response.redirect;
}

Hope the above will help because I had the same problem


You can return the JSON from server with redirect status and redirect URL.

{"redirect":true,"redirect_url":"https://example.com/go/to/somewhere.html"}

And in your jQuery ajax handler

success: function (res) {
    // check redirect
    if (res.redirect) {
        window.location.href = res.redirect_url;
    }
}

Note you must set dataType: 'json' in ajax config. Hope this is helpful.

Tags:

Ajax

Jquery