doutangu4978 2012-09-27 05:57
浏览 41
已采纳

如何使用ajaxform插件和php

i'm trying to use ajaxform plugin with php , please help me I couldn't catch my goal which is

1- the user fill this form ,(( even I want the user to upload a picture but I did my best in coding with no much result so I deleted input type="file" , if you have an idea how to handle this in ajaxform and php please edit my form ))

  < form name="signup" autocomplete="on" id="signup_form" method="get" action="signup_feed.php">
<fieldset>
<legend>Sign Up</legend>
<label class="span-4" >First Name*:</label> <input type="text" id="u_fname" name="u_fname"/><br/>
<label class="span-4">Last Name*:</label><input type="text" id="u_lname" name="u_lname"/><br/>
<label class="span-4">Email*:</label><input type="email" id="u_email" name="u_email"/><br/>
<label class="span-4">Password*:</label><input type="password" id="u_pass" name="u_pass"/></br>
<label class="span-4">Re-type Password*:</label><input type="password" name="u_re_pass"/></br>
<label class="span-4">Phone no.:</label><input type="tel" id="u_phone" name="u_phone" /><br/>

<input type="submit"  value="Sign up" class="button" id="sign_up_btn"/>
</fieldset>
</form>

2- using ajaxform I want values of above form to be submitted , after that there's a countdown 5 seconds to redirect to sign_in.php page

    var options = {

target:'#sign_up_div',
success: function(){
$('#sign_up_div').replaceWith("<div id='signup_success_msg' class='success'></div>");  
        $('#signup_success_msg').html("<h3>You have registered ! </h3>")  
        .hide()  
        .fadeIn(1500, function() {  
          $('#signup_success_msg').append("<img id='checkmark' src='img/icon-check.png' />"); 

        });  
        $('#signup_success_msg').append('<p>please sign up</p>').delay( 2500 ).fadeOut(1500, function() { $(this).remove(); });

},
url:signup_feed.php,
type:post

};

 $('#signup_form').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 

        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 

3- php use redbeansphp to store data

$user = R::dispense( 'user' );
        $user->u_fname=$_GET['u_fname'];
        $user->u_lname=$_GET['u_lname'];
        $user->u_email=$_GET['u_email'];
        $user->u_pass=$_GET['u_pass'];
        $user->u_phone=$_GET['u_phone'];

        $id = R::store($user);

        echo "<p> Thank you for resigteration! Please sign in  </p><p id='countdown'></p> 
        <p>if you still see this page , please <label><a href='sign_in.php'>click here</a></label> </p>";

I'm still new at Jquery but I really want to achieve these goals in my forms ..

  • 写回答

2条回答 默认 最新

  • dtdd25012 2012-09-27 06:15
    关注
    $('form[name="formName"]').ajaxForm({
        success : function (response) {
    
            alert("submitted");
        }
    }).submit()  
    

    This is working ajaxform in my project. try this.

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

报告相同问题?

悬赏问题

  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据