It seems to be possible to set a timeout value when doing an Ajax request in plain javascript. see How to detect timeout on an AJAX (XmlHttpRequest) call in the browser?
It is also possible when using jQuery's ajax implementation, & other similar frameworks I assume. see Set timeout for ajax (jQuery)
Browsers seem to have rather vague specification regarding their default timeout. see Browser Timeouts
Hence one might "hey, I'm going to set a timeout to my ajax request so all the users will have the same timeout".
But then, the next question follow: would it actually override the browser's timeout in all cases?
When I say "all" cases, I mean for instance, if the browser timeout value is smaller than your ajax request timeout value.
I suspect it does not.
And I also suspect it is best practice to always have a timeout error handler to make sure that whatever happens you can display a relevant message that will save hours of work to your support team, & money to your company. see Determine if $.ajax error is a timeout
Thanks in advance
Working of ajax timeout option ajax( '/jquery/submitData', { type : “GET”, timeout : 100 });”, where the first parameter is the URL from where the data will get and the request timeout setup for 100 milliseconds. So, if the request does not completed within 100 milliseconds, then it terminates automatically.
JIRA has a default AJAX timeout period so that requests in the browser do not run for unlimited amounts of time. Normally 30 seconds is plenty of time for a typical data request. AJAX timeouts can be caused by many different things.
The default timeout for browser sessions is 1 hour (3600 seconds). For services, the default is 600 seconds. You can override these defaults with other values (in seconds) by adding a configuration setting named prconfig/timeout/browser/default and a value of 1800 (for thirty minutes).
Most web browsers seem have a “time-out” or “keep-alive” parameter of a few minutes. This means that if there is no network traffic between your device and the web page on the server, the browser will automatically break the connection.
It is an interesting question, I made some experiments in Chrome 59.0 and Firefox 54.0 using a 10min delay service as the backend.
After some test setting the timeout on the client to 10 minutes I had an error response with text status "error" after 300 seconds (5 minutes) in both browsers, so at least for these two browsers it is not possible to override the internal timeout value. I am assuming the same behavior for the remaining browsers in the market.
My test script: (similar results for vanilla JavaScript)
var st = new Date();
$.ajax({
url: "https//mysitewith10minresponse.com/foobar",
type: "GET",
dataType: "json",
timeout: 600000,
success: function(response) { console.log(response); },
error: function(jqXHR, textStatus, errorThrown) {
st = (new Date() - st)/1000;
alert("Text Status " + textStatus + ", diff: " + st + " seconds");
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With