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().
4 Comments
hwjp
my tests suggest erkmene, above, is actually right - the browser sets the timeout...
Nick Craver
@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 raw setTimeout(myFunc,0);, it's about jQuery's .ajax() implementation when one's not specified. The default is still undefined, but behaves like 0 in checks as you can see here. The default for jQuery (what the question was asking) is still effectively 0.hwjp
Sure - 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...
Kurt
Another thing to note is that jQuery AJAX timeout only works if the "async" setting is set to true, which is by default.