如何使用jquery $ .ajax重定向页面

时间:2016-06-28 10:01:06

标签: javascript jquery ajax

这是一个简单的问题。我希望在ajax成功后重定向到另一个页面。我的代码是

if (page != 'Theatres') {
    $('.hexagon').removeClass('active');
    $(this).addClass('active');
    $.ajax({
        url: '{{ url("dashboard/user/set-home-page-preference") }}',
        data: {
            'page': page
        },
        type: 'GET',
        success: function(data) {
            alert(data);
        }
    });
}

我想在警报数据后重定向到一个页面。

1 个答案:

答案 0 :(得分:1)

只需在成功部分

中使用window.location.href = "http://stackoverflow.com";即可

请参阅How can I make a page redirect using jQuery?