我有一个 loginout.php 像:
<?php if($isLoggedIn) { ?>
<form method="POST" action="" name="logoutForm" id="logoutForm" accept-charset='UTF-8'>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type="submit" name="logout" value="Logout" />
</form>
<? } else { ?>
<form method="POST" action="" name="loginForm" id="loginForm" accept-charset='UTF-8'>
<input type='hidden' name='submitted' id='submitted' value='1'/>
Email: <input type="text" name="usr" /><br />
Password: <input type="password" name="pw" /><br />
<input type="submit" name="login" value="Login" />
</form>
<? }?>
一个像
<div id="loginLogoutDiv"></div>
还有jquery代码:
$(document).ready(function(){
$('#loginLogoutDiv').load('loginout.php');
$('#loginForm, #logoutForm').live('submitted', function() {
$.post('loginout.php', $(this).serialize(), function (
data, textStatus) {
$('#loginLogoutDiv').html(data);
});
return false;
});
});
如果按下登录按钮有什么问题,然后整个页面被刷新,我不想要?
谢谢