[英]Jquery : Refresh/Reload the page on clicking a button
I have a button which loads after a ajax call , on clicking i want to reload the page (like i press f5)我有一个在 ajax 调用后加载的按钮,点击后我想重新加载页面(就像我按 f5)
I tried我试过了
$( ".delegate_update_success" ).click(function() {
location.reload();
});
but it does a simple refresh, but my page does not makes a new request to get the contents.但它做了一个简单的刷新,但我的页面没有发出新的请求来获取内容。 It should happen just like I am entering URL to get that page.
它应该像我输入 URL 以获取该页面一样发生。
You should use the location.reload(true)
, which will release the cache for that specific page and force the page to load as a NEW page.您应该使用
location.reload(true)
,它将释放该特定页面的缓存并强制该页面作为新页面加载。
The true
parameter forces the page to release it's cache. true
参数强制页面释放它的缓存。
If your button is loading from an AJAX call, you should use如果您的按钮是从 AJAX 调用加载的,您应该使用
$(document).on("click", ".delegate_update_success", function(){
location.reload(true);
});
instead of而不是
$( ".delegate_update_success" ).click(function() {
location.reload();
});
Also note the true
parameter for the location.reload
function.还要注意
location.reload
函数的true
参数。
使用document.location.reload(true)
它不会从缓存中加载页面。
你也可以使用window.location.href=window.location.href;
Use this line simply inside your head with在你的头脑中简单地使用这条线
window.location.reload(true);
It will load your current page or view.它将加载您当前的页面或视图。
使用window.location.href = url
simple way can be -简单的方法可以是 -
just href="javascript:location.reload(true);
只是
href="javascript:location.reload(true);
your answer is你的答案是
location.reload(true);
Thanks谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.