Does anyone know what the default jQuery ajax timeout value is?
1 Answer
The default is 0
(technically it's undefined, but behaves as 0). This means no timeout in jQuery itself...if the browser has some timeout it's entirely possible you'll hit that.
Only when a timeout
option is specified does jQuery even call setTimeout()
.
-
my tests suggest erkmene, above, is actually right - the browser sets the timeout...– hwjpSep 5, 2012 at 10:42
-
2@hwjp - the line number in the source has changed in recent versions, but the answer above is still correct, note the
timeout > 0
check in jQuery itself: github.com/jquery/jquery/blob/master/src/ajax.js#L700 This isn't a question about rawsetTimeout(myFunc,0);
, it's about jQuery's.ajax()
implementation when one's not specified. The default is stillundefined
, but behaves like 0 in checks as you can see here. The default for jQuery (what the question was asking) is still effectively 0. Sep 5, 2012 at 11:57 -
11Sure - I just think most people care more about what the effective timeout is.... So the best answer would say "by default the timeout is set by the browser" - followed by a technical explanation of whys + hows...– hwjpSep 5, 2012 at 15:27
-
Another thing to note is that jQuery AJAX timeout only works if the "async" setting is set to true, which is by default.– KurtDec 29, 2014 at 9:42