jQuery - 在ajax调用之后重定向

Ian*_*gan 12 javascript jquery

我有以下代码,但是我有一个问题,使window.location工作

$('.test_container a').click(function() {

    $.ajax({
            url: $(link).attr('href'),
            type: 'GET',
            dataType: 'json',
            beforeSend: function() {
                $('#lightbox').show();
            },
            success: function(data) {
                $('#lightbox').hide();

                window.location(data);
            }
        });


    return false;
});
Run Code Online (Sandbox Code Playgroud)

如果使用window.location.replace而它确实有效,但是这不允许brwser后退按钮工作.

有谁知道任何解决方案?

谢谢

Sar*_*raz 16

代替:

window.location(data);
Run Code Online (Sandbox Code Playgroud)

使用:

window.location = data;
Run Code Online (Sandbox Code Playgroud)

location是对象的属性window不是方法.