[英]Redirection not working when inserting value?
視圖:
<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";
}
}
在我看來,我已經為移動驗證創建了一個模型。 現在,當我將手機號碼放在文本框中時,值將存儲到數據庫中,但不會重定向。 在重定向內部,我使用批量短信過程,通過該過程我向客戶端發送消息。 所以,我該怎么辦?請幫助我。
謝謝
您正在使用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
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.