Change success page with jQuery $ .ajax

This is a silly simple question, but I kept looking at it all night and could not understand. I need to change the page to sucess, right now I can get it to work only with .load to load the div from the desired page. I want it to redirect to the entire page.

That's what i

success: function(data) {
    if (data=="Error") {
    $("#error").show();
    $("#processing").hide();
    } else {
        $("#contain").load("finalPage.php #desiredDiv");
    }
}

I just want him to go to this page and not load it. window.load does not work

+3
source share
1 answer

Once installed window.location.href, you force the browser to redirect, for example:

success: function(data) {
    if (data == "Error") {
        $("#error").show();
        $("#processing").hide();
    } else {
        window.location.href = "finalPage.php";
    }
}
+8
source

Source: https://habr.com/ru/post/1773563/


All Articles