Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change page on success with jQuery $.ajax

Tags:

jquery

ajax

This is a stupid simple question, but ive been staring at it all night and can't get it right. I need to change the page on sucess, right now I can only get it to work using .load to load a div from the desired page. I want it to redirect to the entire page.

Here is what I have

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

I just want it to go to that page instead of loading a chunk of it. window.load isn't working

like image 949
Dirty Bird Design Avatar asked Nov 30 '25 17:11

Dirty Bird Design


1 Answers

By setting window.location.href you'll cause the browser to redirect, like this:

success: function(data) {
    if (data == "Error") {
        $("#error").show();
        $("#processing").hide();
    } else {
        window.location.href = "finalPage.php";
    }
}
like image 191
Nick Craver Avatar answered Dec 03 '25 09:12

Nick Craver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!