views:

21

answers:

1

Hi,

I have the following code, however im having 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

A: 

Instead of:

window.location(data);

Use:

window.location = data;

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

Sarfraz
Thanks, spot on!
Ian morgan
@Ian morgan: You are welcome...
Sarfraz