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 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值