Javascript window.location.reload();仅当与alert()一起使用时才起作用;
我正在使用此代码在checkbbox单击时重新加载我的页面-Javascript window.location.reload();仅当与alert()一起使用时才起作用;,javascript,alert,Javascript,Alert,我正在使用此代码在checkbbox单击时重新加载我的页面- <script type="text/javascript"> function showInactive(cb){ $.get('showInactive', function(data) { }, 'json'); alert(); location.reload(); } function hideInactive(cb){ $
<script type="text/javascript">
function showInactive(cb){
$.get('showInactive', function(data) { }, 'json');
alert();
location.reload();
}
function hideInactive(cb){
$.get('hideInactive', function(data) { }, 'json');
alert();
location.reload();
}
</script>
功能显示不活动(cb){
$.get('showInactive',函数(数据){},'json');
警惕();
location.reload();
}
功能隐藏(cb){
$.get('hideInactive',函数(数据){},'json');
警惕();
location.reload();
}
这工作正常,但当我删除警报()时;此代码不起作用。您的错误是如何调用$.get。查看API 我猜您的location.reload()应该在callback中
<script type="text/javascript">
var url = 'http://google.com';
function showInactive(cb){
$.get(url, function(data) {
location.reload();
}, 'json');
}
function hideInactive(cb){
$.get(url, function(data) {
location.reload();
}, 'json');
}
</script>
var url='1〕http://google.com';
功能显示不活动(cb){
$.get(url,函数(数据){
location.reload();
}“json”);
}
功能隐藏(cb){
$.get(url、函数(数据){
location.reload();
}“json”);
}
这可能对您有所帮助
<script type="text/javascript">
function showInactive(cb){
$.get('Use path of your file', function(data) {}, 'json');
window.location.reload();
}
function hideInactive(cb){
$.get('Use path of your file', function(data) {}, 'json');
window.location.reload();
}
</script>
功能显示不活动(cb){
$.get('Use path of your file',function(data){},'json');
window.location.reload();
}
功能隐藏(cb){
$.get('Use path of your file',function(data){},'json');
window.location.reload();
}
$.get('showInactive',函数(数据){},'json')代码>似乎没有做任何有用的事情。您试图用它实现什么?站点注意:location.reload()
也可以从缓存中重新加载站点。如果要重新加载真实站点,请使用location.reload(true)
。。。