admin管理员组文章数量:1181432
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();
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();
Share
Improve this question
edited Jun 20, 2012 at 7:37
gdoron
150k59 gold badges301 silver badges371 bronze badges
asked Jun 20, 2012 at 7:24
Om MOm M
2011 gold badge3 silver badges11 bronze badges
6
- I just tested and it work. Anything showing in the Chrome's JavaScript console? – Alvin Wong Commented Jun 20, 2012 at 7:40
- Do you mean you (1) get an AJAX response (2) reload the page (3) then the content is gone? – Alvin Wong Commented Jun 20, 2012 at 8:21
- yes for eg. am deleting the selected music file from drop down list through ajax in response am getting deleted successfully. To get the latest list am reloading the current page, at this movement the remaining filed content is also going and displaying empty. – Om M Commented Jun 20, 2012 at 13:33
- Of course they are gone because you refreshed the page and your old content generated dynamically (or the user has input) will not be saved. – Alvin Wong Commented Jun 20, 2012 at 13:46
- 1 -1 and voting to close since you haven't given us a minimal example (supposedly there's an Ajax request involved in this, which presumably is in some way crucial, but you haven't shown us any code involving Ajax) and you haven't explained clearly what the actual problem is; you've stated "the content which I want display empty" but firstly because of the broken grammar I can't tell if you mean you want the content to be empty but it isn't, or vica versa, and secondly it's unclear what, if anything, this has to do with either the Ajax request or the page reload. This is unintelligible. – Mark Amery Commented Sep 20, 2016 at 23:06
7 Answers
Reset to default 16Not 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);
try the below:
window.location = self.location;
above code does not work for some browsers, you can even try:
location.reload( true );
you can also try
window.location.href = window.location;
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.
Try this to reload page using JavaScript.
window.location.href = window.location.href;
Try this:
window.opener.location.reload(true);
window.self.close();
This works for me on all major browsers.
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(){
}
本文标签: javascriptwindowlocationreload() not working for Google chromeStack Overflow
版权声明:本文标题:javascript - window.location.reload(); not working for Google chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738168990a2066947.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论