dongshungou7699 2013-12-25 09:21
浏览 47
已采纳

Jquery .live在请求中传递参数两次

I am creating simple login screen which will accept username & password on click of submit button.I tried using .click but its not working at all so i am using .live but its passes same parameter twice in request.

$("#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;
 });

This is what i am getting in request

pusername=&ppassword=&pusername=abc&ppassword=abc

I am using jquery first time and there is something called pretty photo used in my template. I guess this pretty photo might be causing issues.

LoginForm1 looks like as follows :

<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'),'','');
    });

});

here

could you please help me to find out the issue.

  • 写回答

2条回答 默认 最新

  • dongzhong8834 2014-01-09 10:13
    关注

    This is, because prettyphoto clones your inline content by opening. After opening your inline content, you have to clear the original content - otherwise you've got everything twice - and if you close prettyphoto, you have to put it back there, if its not dynamic generated. Example: $.fn.prettyPhoto({ ajaxcallback:function(){ $("#yourhiddenformid").html(""); }, callback:function(){ no need, if its dynamic generated, otherwise: rewrite html of div; }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题