I tried window.location.reload and location.href="page.php". I also tried location.href="http://www.google.com"; that didn't work in any browser. Here's a full example:
PHP Code:
<?php
session_start();
?>
<link href="css.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$('#login').live('click', function() {
$.post("login.php", {user : $("#user").val(), pass : $("#pass").val()},
function(data){
$('#status').html();
if (data == "\r\nReload" || data == "Reload") {
location = 'header.php';
}
if (data == "\r\nLogin Failed") {
$('#status').html('<span style="color:#f00; font-weight:bold;">Sorry, login failed. Please try again.</span>');
}
});
});
$('#logout').live('click', function() {
$.post("login.php", {logout : true},
function(data){
if (data == "\r\nReload" || data == "Reload") {
location.reload();
}
});
});
</script>
<body>
<div class='header'>
<?php if(!isset($_SESSION['userid'])) {?>
<div id="status"></div>
<div class="login">
<form method="post">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="200px;"> </td>
<td width="107"><a class="top_link" href="http://www.jove.com/index/Forgot Password.stp">Forgot Password</a></td>
<td width="83"><a class="top_link" href="http://www.jove.com/index/CreateAccountF.stp">New Account</a></td>
<td width="100"><input type="text" class="input_top login_name" name="login" value="Email" id="user" /></td>
<td width="100"><input type="password" class="input_top login_pass" name="pass" id="pass" value="Password"/></td>
<td width="69"><input type="button" class="submit" value="Sign In" id="login" /></td>
</tr>
</table>
</form>
</div>
<?php } else {?>
<div class="logout" id="logout"><a href="">Log Out</a></div>
<?php } ?>
<div class="clr"></div>
</div>
<script type="text/javascript">
$('#pass').keydown(function(e) {
if (e.keyCode == '13') {
$('#status').html();
$.post("login.php", {user : $("#user").val(), pass : $("#pass").val()},
function(data){
if (data == "\r\nReload" || data == "Reload") {
location = 'header.php';
}
if (data == "\r\nLogin Failed" || data == "Login Failed") {
$('#status').html('<span style="color:#f00; font-weight:bold;">Sorry, login failed. Please try again.</span>');
}
});
}
});
</script>
The reload comes through I tested that with breakpoints. found that I needed the \n\r also because that comes through some of the time.
Bookmarks