doubi5520 2017-12-07 07:25
浏览 46
已采纳

插入值时重定向无效?

view:

<script>
        $(document).ready(function(){
            $("#verify").click(function(event){
                event.preventDefault()
                mobile = $("#mobile").val();
                uid = $("#uid").val();
                $.ajax({
                    type:"POST",
                    data:{"mobile":mobile, "uid":uid},
                    url:"<?php echo base_url(); ?>quiz/mobile_verification",
                    success:function(data){
                        alert(data);
                    }
                });
            });
        });
    </script>
    <li><a href="javascript:void(0)" data-toggle="modal" data-target="#mobiles">Result</a></li>
    <div id="mobiles" class="modal fade" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-body">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <p style="text-align:center;color:red;">Your mobile number is not verify</p>
            <p style="text-align:center;color:red;">Please enter your mobile number for verification to see result.</p>
            <input type="hidden" name="uid" id="uid" value="<?php echo $uid; ?>">
            <center>Enter Your Valid Number :<input type="text" name="mobile" id="mobile" onkeyup="check(); return false;"/>
            <p id="message" style="margin-bottom: 0px;"></p>
            <input type="submit" name="verify" id="verify" class="btn btn-success" value="Verify" style="margin-top:10px;"/></center>
          </div>
        </div>
      </div>
    </div>

controller:

public function mobile_verification()
{
    $data['logg'] = $this->session->userdata('logged_in');
    $mobile = $this->input->post('mobile');
    $uid = $this->input->post('uid');
    $password = rand(10,10000);

    $data = array(
                "uid"=>$uid,
                "mobile"=>$mobile,
                "password"=>$password,
                );
    $sql = $this->db->insert('mobile_verify',$data);
    if($sql = true)
    {
        redirect("quiz/verify");
    }
    else
    {
        echo "error";
    }
}

In my view I have create a model over result for mobile verification. Now , when I put mobile number inside text box value will store into database but it not redirect. Inside redirect I am using bulk sms process through which I am sending message to client. So, How can I do this ?Please help me.

Thank You

  • 写回答

1条回答 默认 最新

  • douxuanma4357 2017-12-07 07:39
    关注

    You are using ajax for mobile varification thats why you can not redirect it from there

    $.ajax({
            type:"POST",
            data:{"mobile":mobile, "uid":uid},
            url:"<?php echo base_url(); ?>quiz/mobile_verification",
            success:function(data){
                            window.location.href= '<?php echo base_url(); ?>quiz/verify';//redirect from here or use $.reload() function
                        }
         });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line