我正在创建简单的登录屏幕,该屏幕将接受用户名&单击提交按钮时的密码。我尝试使用.click但它根本不工作所以我使用.live但它在请求中传递了两次相同的参数。
$("#loginsubmit").live('click', function (e) {
$.ajax({
url: 'auth_check.php',
data: $(loginForm1).serialize(),
type: 'POST',
cache: false,
success: function (result) {
if (result == 'success') {}
},
error: function (result) {}
});
e.preventDefault();
$.prettyPhoto.close();
return false;
});
这是我要求的
pusername =安培; ppassword =安培; pusername = ABC&安培; ppassword = ABC
我第一次使用jquery,在我的模板中使用了一些名为pretty photo的东西。 我想这张漂亮的照片可能会导致问题。
LoginForm1如下所示:
<div class="login_register_stuff hide"><!-- Login/Register Modal forms - hidded by default to be opened through modal -->
<div id="login_panel">
<div class="inner-container login-panel">
<h3 class="m_title">SIGN IN YOUR ACCOUNT TO HAVE ACCESS TO DIFFERENT FEATURES</h3>
<form name="loginForm1" method="post" enctype="multipart/form-data" />
<a href="#" class="create_account" onclick="ppOpen('#register_panel', '280');">CREATE ACCOUNT</a>
<input type="text" name="pusername" class="inputbox" placeholder="Username" />
<input type="password" name="ppassword" class="inputbox" placeholder="Password" />
<input type="submit" id="loginsubmit" name="loginsubmit" value="LOG IN" />
</form>
<div class="links"><a href="#" onclick="ppOpen('#forgot_panel', '350');">FORGOT YOUR USERNAME?</a> / <a href="#" onclick="ppOpen('#forgot_panel', '350');">FORGOT YOUR PASSWORD?</a></div>
</div>
prettyphoto section snippet
enter <!-- prettyphoto scripts & styles -->
function ppOpen(panel, width){
jQuery.prettyPhoto.close();
setTimeout(function() {
jQuery.fn.prettyPhoto({social_tools: false, deeplinking: false, show_title: false, default_width: width, theme:'pp_kalypso'});
jQuery.prettyPhoto.open(panel);
}, 300);
} // function to open different panel within the panel
jQuery(document).ready(function($) {
jQuery("a[data-rel^='prettyPhoto'], .prettyphoto_link").prettyPhoto({theme:'pp_kalypso',social_tools:false, deeplinking:false});
jQuery("a[rel^='prettyPhoto']").prettyPhoto({theme:'pp_kalypso'});
jQuery("a[data-rel^='prettyPhoto[login_panel]']").prettyPhoto({theme:'pp_kalypso', default_width:800, social_tools:false, deeplinking:false});
jQuery(".prettyPhoto_transparent").click(function(e){
e.preventDefault();
jQuery.fn.prettyPhoto({social_tools: false, deeplinking: false, show_title: false, default_width: 980, theme:'pp_kalypso transparent', opacity: 0.95});
jQuery.prettyPhoto.open($(this).attr('href'),'','');
});
});
这里
你可以帮我找出问题。答案 0 :(得分:0)
您必须在表单上绑定onsubmit事件:
$("#loginForm1").on('submit', function (e) {
$.ajax({
url: 'auth_check.php',
data: $('#loginForm1').serialize(),
type: 'POST',
cache: false,
success: function (result) {
if (result == 'success') {}
},
error: function (result) {}
});
e.preventDefault();
$.prettyPhoto.close();
return false;
});
答案 1 :(得分:0)
这是因为prettyphoto通过打开来克隆你的内联内容。打开你的内联内容之后,你必须清除原始内容 - 否则你已经完成了两次 - 如果你关闭了prettyphoto,你必须把它放回去,如果它不是动态生成的。
例:
$.fn.prettyPhoto({
ajaxcallback:function(){
$("#yourhiddenformid").html("");
},
callback:function(){
no need, if its dynamic generated, otherwise:
rewrite html of div;
}