How to continue run ajax call after redirect to another page in PHP?
How to go from one page to another page when Ajax call is on in PHP?
My ajax call is performing a very complex task and it will take a longtime So, Is it possible to run an ajax call after page redirect?
I make ajax call on submit button click and after that page redirects on another page and then my ajax call is Continue Running in Backend.<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<title></title>
</head>
<body>
<input type="text" name="altname" id="altname">
<button id="btnSubmit">Submit</button>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click','#btnSubmit',function(){
var altname = $("#altname").val();
$.ajax({
url:"http://localhost/z/backend-queue-job-php/queue_job.php",
type:"POST",
data:{altname:altname},
success:function(result)
{
alert(result.msg);
}
});
window.location.href = "http://localhost/z/backend-queue-job-php/thankyoupage.php";
});
});
</script>