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 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了