开发者

jQuery - redirect after ajax call

I have the following code, however im havin开发者_JAVA百科g a problem getting window.location to work

$('.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;
});

If window.location.replace is used instead it does work, however this then doesnt allow the brwser back buttons to work.

Does anyone know of any solution?

Thanks


Instead of:

window.location(data);

Use:

window.location = data;

The location is a property of the window object not a method.


for some reason, i tried

window.location = data;

without success, but when used

document.location.href = data;

it worked, you can consider this too

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜