视图:
<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">×</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>
控制器:
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";
}
}
在我看来,我已经为移动验证创建了一个结果模型。现在,当我将移动号码放在文本框内时,值将存储到数据库中,但不会重定向。内部重定向我正在使用批量短信进程,通过它我向客户端发送消息。那么,我该怎么办呢?请帮帮我。
谢谢
答案 0 :(得分:1)
您正在使用ajax进行移动设备修改,这就是为什么您无法从那里重定向
$.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
}
});