Om M
Om M

Reputation: 201

window.location.reload(); not working for Google chrome

I am using AJAX action after getting the response, I want to reload the current page, for which I am using:

 window.location.reload();

It works fine on Firefox and IE, but it's not working for Chrome; the content which I want display empty.

Is there way to reload the page in chrome?

window.opener.document.location.reload();
self.close();

Upvotes: 13

Views: 59453

Answers (7)

osaru agbonaye
osaru agbonaye

Reputation: 97

If you are working with AJAX, you have to do the reload inside the success function.

$.ajax({
    type: 'POST',
    data: '',
    url: '',
    success: function(data){
        setTimeout(function(){
            window.location.reload();
        },100);
    },
    error: function(){
}

Upvotes: -2

1JD
1JD

Reputation: 325

Try this:

window.opener.location.reload(true);
window.self.close();

This works for me on all major browsers.

Upvotes: -2

Michaja Broertjes
Michaja Broertjes

Reputation: 612

Not sure why, but in my case i fixed it by wrapping the reload() call in a setTimeout with 100 ms.

setTimeout(function(){
    window.location.reload();
},100); 

Upvotes: 16

pratik nagariya
pratik nagariya

Reputation: 574

Try this to reload page using JavaScript.

window.location.href = window.location.href;

Upvotes: -2

kreddle
kreddle

Reputation: 1

Try:
parent.window.location.reload();
This doesn't work in Firefox 17 for me.

The only other way I know that works in all browsers is to redirect to another blank page and redirect back to the current page.

Upvotes: -1

Gupta Vini
Gupta Vini

Reputation: 530

try the below:

window.location = self.location;

above code does not work for some browsers, you can even try:

location.reload( true ); 

Upvotes: 8

AO_
AO_

Reputation: 2894

you can also try

window.location.href = window.location;

Upvotes: 0

Related Questions