I have an heavy app where everything is in ajax .
Now sometime there is 10+ ajax request when a page loads and some of them randomly fail for an unknown reason to me .
Is there anyway to know why those requests failed ?
I can catch the error inside the error: {} case , should i call the Ajax function again in case of a failure or its not a good idea (avoiding loops) ?
This is the Ajax function that i use to process all my requests :
function ajax(aurl,dataType,requestData,successListener,compelteListener,errorListener,async) {
var $xhr=null;
async = typeof async !== 'undefined' ? async : true;
if($.ajax) {
$xhr=$.ajax({
type: 'post',
url : aurl,
async : async,
dataType : dataType,
data:requestData,
success: function(response){
checkAjaxResponse(null,response,successListener,errorListener);
},
complete:compelteListener,
error:function(response){
checkAjaxResponse(null,response,errorListener);
}
});
}else {
alert("jquery not found ..");
}
return $xhr;
}
Update 1 :
If i do a console.log on response inside the error , i get the following :
{"readyState":0,"responseText":"","status":0,"statusText":"error"}
Update 2:
Looking at the apache log i see a lot of :
[notice] Parent: child process exited with status 255 -- Restarting.
I also modified my ajax request to :
error:function(response){
ajax(aurl,dataType,requestData,successListener,compelteListener,errorListener,async);
}
But that might crash the system if the Ajax always fails ...
Update #3
I think its more of a WAMP issue , because i don't have those error on production .
Anyway thank you all for your effort !
Issue was related to Apache on windows for an unknown reasons server crashed randomly .
I found some info related to stack on the httpd (1mb windows default vs 8mb default on linux)
Our production was linux and dev on windows .
Modified the function to the following :
error:function(response){
counter++;
checkAjaxResponse(null,response,errorListener);
if(counter > 5) {
jAlert(get_label('technical_error') + '<br><br>' + get_label('function_called')+ aurl,get_label('attention_loading'));
setLoading(false);
} else {
return ajax(aurl,dataType,requestData,successListener,compelteListener,errorListener,async,counter);
}
}