I have a very simple PHP script:
ini_set('max_execution_time', 240000);
//Switch for terminating the test processing status loop
$completed = false;
while ($completed == false) {
sleep(2);
}
This is launched using AJAX which is again, very simple:
$.ajax({
url: "lib/check_processing_status.php",
timeout: 0,
async: true,
error: function() {
console.log("FAILURE");
},
success: function() {
console.log("SUCCESS");
}
});
This script should run indefinitely, or at least until the timeout is triggered. Yet it fails after a duration which differs each time it is run. Sometimes just 40 seconds, sometimes 1 minute and 10 seconds.
Why is this failing!?
Additional:
Just to add some context, the reason I am having a loop like this, is because I will be querying a server for the progress of a process, so instead of calling loads of AJAX requests every 5 seconds (filling up the console window with 10's of requests), I figured it neater to stay inside the PHP script until the process is complete and then return when its complete.