我正在从jQuery的FancyBox中加载内联注册表单。然而,在提交表单后,该框会立即关闭,同时有一些反馈意见让我想在FancyBox中显示用户。此反馈在服务器端生成并打印在FancyBox中。如何防止提交后立即关闭jQuery FancyBox?
如何让箱子只在他们没有反馈时关闭?我正在考虑使用ajax刷新FancyBox本身,而不是刷新后的整个页面。但我只是无法弄清楚这是如何ajax $ .ajax({类型,缓存,网址,数据,成功});工作......另外,它似乎没有从JavaScript中的'提交绑定'的反应。
我希望有人能帮助我解决这个问题。我在下面粘贴我的代码。如有任何疑问,请询问..
Thx提前!
这是JavaScript:
<script type="text/javascript">
$(document).ready(function() {
$("#various1").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'scrolling' : 'no',
'titleShow' : false,
'onClosed' : function() {
$("#registration_error").hide();
}
});
});
$("#registration_form").bind("submit", function() {
if ($("#registration_error").val() != "Registration succeeded!") {
$("#registration_error").show();
$.fancybox.resize();
return false;
}
$.fancybox.showActivity();
$.ajax({
type : "POST",
cache : false,
url : "/data/login.php",
data : $(this).serializeArray(),
success : function(data) {
$.fancybox(data);
}
});
return false;
});
这是直列形式,我显示在的fancybox:
<div style="display: none;">
<div id="registration" style="width:227px;height:250px;overflow:auto;padding:7px;">
<?php echo "<p id=\"registration_error\">".$feed."</p>"; ?>
<form id="registration_form" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<p>
<label for="username">Username: </label>
<input type="text" id="login_name" name="username" size="30" />
</p>
<p>
<label for="password">Password: </label>
<input type="password" id="pass" name="pw" size="30" />
</p>
<p>
<label for="repeat_password">Repeat password: </label>
<input type="password" id="rep_pass" name="rep_pw" size="30" />
</p>
<p>
<input type="submit" value="Register" name="register" id="reg" />
</p>
<p>
<em></em>
</p>
</form>
</div>
</div>