0

有人可以帮助我吗,我正在使用一个名为 shadowbox 的 jquery 灯箱。基本上,如果用户单击我网站上的链接,这些链接会使用以下代码在 jquery 窗口中打开:

<a href="page.php" rel="shadowbox;height=300;width=500">link</a>

但现在我试图通过这样的编码来获取提交时的登录 html 表单以在 jquery 窗口中打开:

<form action="login.php"  rel="shadowbox;height=300;width=500" method="post" class="loginform">

    Email
    <input type="text" name="email" maxlength="30" />

    Password
    <input type="password" name="password" maxlength="30" />

    <input type="image" src="../PTB1/assets/img/icons/loginarrow1.png" name="submit" class="loginbutton" value="Login" />

</form>

目前虽然它没有在 jquery 窗口中打开,并且在登录时只是使用相同的预先存在的页面。有人可以告诉我我能做什么。谢谢。

4

1 回答 1

0

您需要在 js 中请求您的表单,如下所示:

<script type="text/javascript">
function showBox(){
Shadowbox.open({
content: '<form action="login.php" method="post" id="login-form" class="loginform">Email<input id="email" type="text" name="email" maxlength="30" />Password<input type="password" id="pass" name="password" maxlength="30" /><input type="submit" id="submit" name="submit" class="loginbutton" value="Login" /></form>',
player: "html",
title: "Login-form",
height: 300,
width: 500
});
}
</script>

<a href="#" onclick="showBox()">Login-form</a>

使用 type="submit" 的输​​入或按​​钮,在登录表单中,您需要使用 ajax-techology 来检查请求数据,如下所示:

$(文档).ready(函数(){

$('#submit').click(function(){
    $('#login-form').submit(function(){ return false;});
     $.ajax({
        type: 'POST',
        url: 'url for check data',
        data: {'email':$('#email').val(),'pass':$('#pass').val()},
        success: function(result){
          if(result == 'ok') $('#login-form').submit();
          else alert('error!');
}
      });
  });
});
于 2013-01-25T15:49:46.577 回答