0

How do I get jquery ajax to remain connected until the external execution of code is done? Code:

$.ajax({
        type: "POST",
    data: "pro=2",
    url:"engine/process.php", // huge data to be processed here and it takes quiet some time
        error: function(){
               alert('error');
        }, 
    success: function(finish){
        //php code is complete
    }
});

the code works but after some few minutes it returns error alert when the connection is lost. that is the alert('error') which is in the code. due to that the php code will not finish processing.

everything works fine on localhost but not when it is uploaded to the server.

  • This doesn't seem to be a frontend issue. Try logging the error you get: `error: function(e){ console.log(e); }` and include it in your question. – NullDev Mar 22 '21 at 12:53
  • Does this answer your question? [How to increase the execution timeout in php?](https://stackoverflow.com/questions/3829403/how-to-increase-the-execution-timeout-in-php) – Alon Eitan Mar 22 '21 at 12:56
  • HTTP isn't meant for connections that are open for long periods of time. You can make it happen, but it's like backing up a semi to the revolving door at the front of a supermarket to offload a bunch of groceries. Sure, it'll get done, but why not use the loading docks? – Heretic Monkey Mar 22 '21 at 12:56

0 Answers0