Javascript 点击链接后刷新div\u空白 函数openWindowReload(链接){ setTimeout(函数(){ var href=link.href; 窗口。打开(href,“空白”); document.location.reload(true) }, 5000); 返回false; }
因此,我有一段代码,在单击“更新”(target=“\u blank”)按钮后,强制刷新(5秒后)当前页面 但我只想重新加载一个特殊的div 说明: 仅当表更新中的字段=false时,“更新”按钮才可见。。。因此,当它为真时,更新按钮不可见。但当你单击按钮更新时,它将首先更新表并将更新设置为真 update.phpJavascript 点击链接后刷新div\u空白 函数openWindowReload(链接){ setTimeout(函数(){ var href=link.href; 窗口。打开(href,“空白”); document.location.reload(true) }, 5000); 返回false; },javascript,php,jquery,Javascript,Php,Jquery,因此,我有一段代码,在单击“更新”(target=“\u blank”)按钮后,强制刷新(5秒后)当前页面 但我只想重新加载一个特殊的div 说明: 仅当表更新中的字段=false时,“更新”按钮才可见。。。因此,当它为真时,更新按钮不可见。但当你单击按钮更新时,它将首先更新表并将更新设置为真 update.php <div id='mydiv'> <a href="update.php" target="_blank" onClick="return openW
<div id='mydiv'>
<a href="update.php" target="_blank" onClick="return openWindowReload(this)">update</a>
</div>
<script>
function openWindowReload(link) {
setTimeout(function(){
var href = link.href;
window.open(href,'_blank');
document.location.reload(true)
}, 5000);
return false;
}
</script>
所以你能帮我实现我的目标吗…使用jquery$.post速记(),例如:
<?php
mysqli_query($con, 'UPDATE TABLE sET updating = TRUE');
(long code in here)
?>
html:
$(document).ready(function(){
$.post( "update.php", function( data ) {
// wrap this with the timeout, if you need
// but the method post is asynchronous already and takes time
$( ".update" ).hide();
});
});
JS-Bin
更新!
就这些!希望这有帮助
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<button class="update">Update!</button>
</body>
</html>