dongsi0625 2016-06-02 13:04
浏览 64
已采纳

在ajax成功函数中显示隐藏的div,用于显示剩余的注册表单

The following is the jquery script for my otp.

<Script>
        $(document).ready(function(){
            $('#otp_submit').click(function(){
                var otp_insert=$('#otp_insert').val();

                $.ajax({
                    url:'smsverify.php',
                    type:'POST',
                    data:{otp_insert:otp_insert},
                     /* beforeSend: function(){
                        $('.image_loading').show();
                    },
                    complete: function(){
                        $('.image_loading').hide();
                    },*/
                    success: function(data){
                        if(data.success==1){
                            $('.hide2show').show();
                            $('html, body').animate({ scrollTop: $('.hide2show').offset().top }, 'slow');

                       }
                            else
                            {
                                    $('.result').html(data);
                            }

                    },
                    error: function() { 
                      console.error('Failed to process ajax !');
                    }
                });
            });
        });

    </Script><!-- Send Otp To the mobile number using ajax -->

This is the script which send data to smsverify.php and now this is my smsverify.php script

<?php

session_start();
$otp_password=$_POST['otp_insert'];
echo $otp_password;


if($_SESSION['otpkey']==$otp_password) {
    echo "OTP is granted using session";

} else {
    echo "otp is not granted not session";
}

?>

This is php script to validate sms otp which send by user.

actually script works fine , but when it returns the data .it is only showing the echo message. not showing the .hide2show class which is contain remaining registration form.

<div class="row">
                    <h4 class=""> <Strong> &nbsp;&nbsp;&nbsp;Primary Details : </Strong></h4>
                    <div class="col-md-3">
                        <label> Your Email - </label>

                    </div>
                    <div class="col-md-6">
                        <input type="text" name="email_user" id="email_user" placeholder="Enter Your Email" class="form-control">
                         <span id="error" style="display:none;color:red;">Wrong Email Id , Kindly Enter valid E-mail Id</span><i class="fa  fa-file-text-o errspan"></i>
                    </div>

                </div><!-- end of emaiol row--><label></label>
                                <div class="row">
                    <div class="col-md-3">
                        <label> Your Mobile Number - </label>
                    </div>
                    <div class="col-md-6">
                       <input type="text" name="mobile_user" id="mobile_user" placeholder="Enter Your Mobile Number ( 10 Numbers Allowed Only)" class="form-control"  required  title=" Wrong Mobile Number , Only 10 Digits Allowed" onkeypress='return isNumberKey(event)'  maxlength="10"><i class="fa fa-lg fa-mobile-phone errspan" ></i> <span id="error_mob" style="display:none;color:red;">Wrong Mobile Number Kindly Enter Valid Number</span>
                    </div>
                    <div class="col-md-3">
                        <input type="button" name="otp_send" id="otp_send" class="btn btn-info btn-block" Value="Send OTP" disabled="disabled">

                    </div>  
                </div><!-- end of emaiol row--><label></label>  
                    <img src="../assets/img/289.gif" class="image_loading" style="display:none;">
                <div class="row hide4otp" style="display:none;">
                    <div class="col-md-3">
                        <label> One Time Password - </label>
                    </div>
                    <div class="col-md-6">
                        <input type="text" name="otp_insert" id="otp_insert" placeholder="Enter One Time Password"  class="form-control" maxlength="5" ><span id="error_otp" style="display:none;color:red;">Wrong OTP , Kinldy Enter a Valid OTO Which You Have Received On Your Mobile</span>
                    </div>
                    <div class="col-md-3">
                        <input type="button" name="otp_submit" id="otp_submit" class="btn btn-danger btn-block" Value="Press Me !!" disabled="disabled">
                    </div>  
                </div><!-- end of emaiol row--><label></label>
                                    <div class="row hide2show">
                                        <h4 class=""> <Strong> &nbsp;&nbsp;&nbsp;Property Information : </Strong></h4>
                                            <div class="col-md-3">
                            <strong>Property For : </strong>
                      </div>
                                            <div class="col-md-6">
                          <select name="proerty_for" id="proerty_for" class="form-control" >
                            <option value="Sale"> For Sale</option>
                                                        <option value="Rent"> For Rent</option>
                          </select>
                                            </div>
                                    </div><!-- end of Property_for--><label></label>

This is html code for your relevnce
  • 写回答

3条回答 默认 最新

  • dousi6701 2016-06-02 13:40
    关注

    Try following code ,it may work for you

    <?php
    
    session_start();
    $otp_password=$_POST['otp_insert'];
    
    if($_SESSION['otpkey']==$otp_password) {
       echo "1";
    } else {
      echo "0";
    }
    
    ?>
    

    and in your ajax response check with

    if(data=='1'){
       // your code
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格