0
我正在注册/登录系统上工作。注册表格与fancybox一起工作。一旦我点击“注册”链接,我就可以在fancybox窗口中看到注册表单。一旦表单被提交,它将运行register.php通过ajax来检查用户名是否已经存在。如果用户名已经存在,则必须显示一条消息。这是有效的,但如果我想再次提交表单,表单会关闭并且不会发生任何其他事情。由于某种原因,javascript函数不运行。任何人都知道我做错了什么,可以帮助我吗?Fancybox不能在第二次点击
的Javascript:
$(function() {
$('#register-form').bind('submit', function() {
$.ajax({
type: 'POST',
cache: false,
url: '/register.php',
data: $(this).serializeArray(),
success: function (data) {
alert('test');
$('#register').html(data);
}
});
return false;
});
});
//代码在什么在打开的fancybox当您单击 '注册' 链接
<div id="fbRegisterCntr" style="display: none;">
<div class="popup">
<div class="inner" id="register">
<h3>Register</h3>
<form method="post" action="" id="register-form">
<fieldset>
<input type="text" name="username" class="field">
<input type="password" name="password" class="field">
<input type="text" name="email" class="field">
<input type="submit" class="button" value="Register">
</fieldset>
</form>
</div>
</div>
</div>
Register.php
echo '
<h3>Register</h3>
<p>Username already exists</p>
<form method="post" action="" id="register-form">
<fieldset>
<input type="text" name="username" class="field" placeholder="Vul hier je gebruikersnaam in..." value="' . $username . '">
<input type="password" name="password" class="field" placeholder="Vul hier je wachtwoord in..." value="' . $password . '">
<input type="text" name="email" class="field" placeholder="Vul hier je e-mailadres in..." value="' . $email . '">
<input type="submit" class="button" value="Registreren">
</fieldset>
</form>';
每一页的页脚