1

我可以让 Ajax 成功发送请求,但我希望它也重定向到新页面并且它没有重定向。任何人都可以建议一种替代方法或正确的重定向方式吗?

submitHandler: function(form) {
    $("div.error").hide();
    $.ajax({
        type: "POST",
        url: '<?php echo base_url().'subscribe/process_payment/'?>',
        data: $(form).serialize(),
        success: function(msg){
            console.log( "Data Saved: " + msg );

        },          

        error: function(msg){
            console.log( "Error: " + msg);
        } 
    });
    return true;
        },
4

1 回答 1

1

通常你可以简单地在成功函数中进行重定向

success: function(msg){
        console.log( "Data Saved: " + msg );
        window.location = "mysite.com/newURL";
},

或返回网址

success: function(url){
        window.location = url;
},
于 2012-11-27T23:34:02.360 回答