开发者

change page on success with jQuery $.ajax

开发者 https://www.devze.com 2023-01-23 18:52 出处:网络
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

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("fi开发者_运维百科nalPage.php #desiredDiv");
    }
}

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


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";
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消