80

Does anyone know what the default jQuery ajax timeout value is?

1

1 Answer 1

90

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().

Sign up to request clarification or add additional context in comments.

4 Comments

my tests suggest erkmene, above, is actually right - the browser sets the timeout...
@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.
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...
Another thing to note is that jQuery AJAX timeout only works if the "async" setting is set to true, which is by default.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.