Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何通过json_编码重定向php页面_Javascript_Php_Json_Mobile - Fatal编程技术网

Javascript 如何通过json_编码重定向php页面

Javascript 如何通过json_编码重定向php页面,javascript,php,json,mobile,Javascript,Php,Json,Mobile,我有两个文件。1是controller.php和2nd verification.js 一旦验证函数成功执行,我需要重定向 Controller.php 第二个文件verification.js 函数sendOTP(){ $(“.error”).html(“”.hide(); var number=$(“#mobile”).val(); 如果(number.length==10&&number!=null){ 变量输入={ “手机号码”:号码, “操作”:“发送otp” }; $.ajax(

我有两个文件。1是controller.php和2nd verification.js 一旦验证函数成功执行,我需要重定向

Controller.php


第二个文件
verification.js

函数sendOTP(){
$(“.error”).html(“”.hide();
var number=$(“#mobile”).val();
如果(number.length==10&&number!=null){
变量输入={
“手机号码”:号码,
“操作”:“发送otp”
};
$.ajax({
url:'controller.php',
键入:“POST”,
数据:输入,
成功:功能(响应){
$(“.container”).html(响应);
}
});
}否则{
$(“.error”).html('请输入有效数字!')
$(“.error”).show();
}
}
函数verifyOTP(){
$(“.error”).html(“”.hide();
$(“.success”).html(“”.hide();
var otp=$(“#mobileOtp”).val();
变量输入={
“otp”:otp,
“操作”:“验证otp”
};
if(otp.length==6&&otp!=null){
$.ajax({
url:'controller.php',
键入:“POST”,
数据类型:“json”,
数据:输入,
成功:功能(响应){
$(“+response.type).html(response.message)
$(“+response.type).show();
},
错误:函数(){
警报(“ss”);
}
});
}否则{
$(“.error”).html('您输入了错误的OTP'。)
$(“.error”).show();
}
}
我不确定,我需要把重定向代码放在哪里。我想,一旦我的手机号码被核实。这应该被重定向到abc.php页面


提前感谢,请帮助我解决此问题。

因为您使用的是AJAX,所以需要在JavaScript中执行
窗口.location
命令,在调用验证后的“success”回调中\u otpy通过AJAX验证后是否要重定向?因此,您不需要
.show
任何response.message(因为您将改为重定向)?另外,我注意到,在PHP中验证OTP时,您没有在会话中放入任何内容来记录OTP是否有效。因此,我不确定你的abc.php页面将如何检查用户是否可以访问它。请帮助我使用代码,窗口。位置不起作用。我更新了代码。但是它不起作用。因为您使用的是AJAX,所以需要在JavaScript中执行
窗口.location
命令,在调用verify后的“success”回调中,通过AJAX进行verify后是否要重定向?因此,您不需要
.show
任何response.message(因为您将改为重定向)?另外,我注意到,在PHP中验证OTP时,您没有在会话中放入任何内容来记录OTP是否有效。因此,我不确定你的abc.php页面将如何检查用户是否可以访问它。请帮助我使用代码,窗口。位置不起作用。我更新了代码。但它不起作用。