Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
88
rated 0 times [  94] [ 6]  / answers: 1 / hits: 22463  / 8 Years ago, thu, october 6, 2016, 12:00:00

I have ajax call where I process large data and then reload the page in ajax success. Ajax call is



        $.ajax({
type:'POST',
cache:false,
async:false,
url: 'URL',
data: ,
timeout:0,
beforeSend:function(msgg){
$('#loading').show();
},
success: function(data){
if(data == success)
{
setTimeout(function(){
$('#loading').hide();
window.location.reload();
},5000);
}
}
});


but it gets 504 GATEWAY_TIMEOUT and ajax call never comes in success. I need manual refresh.


More From » ajax

 Answers
5

The recommendation is to make more short calls to check status / retrieve data.



Here is the alternative if the above is not possible:




Notice: This solution is not recommended for production use or high traffic scenarios, make sure this action is performed on an isolated server.




If using Apache Web Server 2.4, the TimeOut directive is by default set to 60 seconds.



For more details see this article.



The web server will only keep the connection open for 60 seconds regardless the max_execution_time



While the max_execution_time in php.ini sets the execution time of php, the Apache TimeOut directive sets the maximum connection time.



Example:




  • if php max_execution_time is 120 sec, but TimeOut is 30 sec - you will get a 504 error

  • if php max_execution_time is 120 sec, but TimeOut is 300 sec - your script will execute for max 120 seconds, but your connection can stay alive for 300 seconds



If you didn't set any response code from php, PHP returns 200 if everything is OK, 500 if error occured.



When you get an unexpected HTTP Response code it's good to keep an eye on the web server too.


[#60484] Tuesday, October 4, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
susanap

Total Points: 413
Total Questions: 82
Total Answers: 99

Location: South Georgia
Member since Mon, Oct 19, 2020
4 Years ago
;