I have a problem with my script, i want to do a POST call, to a script file.php, and then call the file2.php every 10000 seconds until timeout when (1800000 seconds pass) OR return the response we want and clear the timeout and output the info
the script is working. the problem i have is this area
if (datareturn == "isgood") {
$("#returninfo").show();
$("#results").hide();
clearTimeout(myVar);
clearTimeout(myVa);
}
the file2.php returns response in json
{"info":"isgood"}
but still it doesn’t clear timeout or show returninfo
when i check the browser file2.php returns very well, and also file.php works, am not seeing any errror in my browser console about jquery or post.
so am confused, i will be glad to get some help
function BtnCk() {
$("#BtnCheck").click(function(event) {
Execute();
});
function Execute() {
$.ajax({
type: "POST",
url: "file.php",
data: {
fullname: $("input[name='fullname']").val(),
},
beforeSend: function() {
if ($("form input[name='fullname']").val() == "") {
$("#report_error").html("<p>input needed</p>");
return false;
}
},
complete: function() {
$("#report_error").hide();
},
success: function(response) {
$("#results").html(response.info);
myVa = setTimeout(() => {
$("#results").hide();
clearTimeout(myVar);
}, 1800000);
setTimeout(Rsponse, 10000);
},
error: function() {
alert("errror .");
},
});
}
}
function Rsponse() {
myVar = setTimeout(Rsponse, 10000);
$.ajax({
type: "POST",
url: "ajax/file2.php",
data: {
fullname: $("input[name='fullname']").val(),
},
success: function(resp) {
var datareturn = resp.info;
if (datareturn == "isgood") {
$("#returninfo").show();
$("#results").hide();
clearTimeout(myVar);
clearTimeout(myVa);
}
},
});
}
$(document).ready(function() {
BtnCk();
});