![](/img/trans.png)
[英]Stop reloading the page after location.reload(); has been called
[英]jquery page not reloading (location.reload)
从查询回显成功消息后,我的页面没有刷新。 我已经尝试过location.reload(),location.reload(true),甚至尝试使用“ loginFunction.php”页面中的标头进行重定向,但似乎无济于事。
jQuery查询
if ($.trim(user) != '' && password != '') {
$.post('includes/loginFunction.php', {
userName: user,
uPassword: password
}, function(data) {
var result = data;
if (data !== "success") {
$('#uNameE').text(data);
} else {
window.location.reload(true);
}
});
}
的PHP
require_once('dbopen.php');
if(isset($_POST['userName']) === true && empty ($_POST['userName']) === false ){
$userName = $_POST["userName"];
$userPass = $_POST["uPassword"];
$query = $conn->query("SELECT * FROM members WHERE userN = '$userName' AND password = '$userPass'");
$num = $query->num_rows;
if($num != 0 ){
$_SESSION['usernameP'] = $userName;
//Header not working neither
//header('location: index.php');
echo "success";
}
else{
echo "Username or password incorrect";
}
}
这有可能是你的.reload()
的POST
在页面重载这可能会导致一个循环再次荷兰国际集团。 尝试:
window.location.href=window.location.href
SO相关问题: window.location.href = window.location.href和window.location.reload()之间的区别
try this :
location.reload();
您也可以调用函数:
function reload(){location.reload();}
放到那里:
reload();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.