79

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

Adriano
  • 19,463
  • 19
  • 103
  • 140
yamspog
  • 18,173
  • 17
  • 63
  • 95
  • 4
    It seems it is undefined and left for the specific implementation in the browser: http://stackoverflow.com/questions/2507355/jquery-ajax-call-default-timeout-value http://stackoverflow.com/questions/3394760/jquery-ajax-timeout-undefined – erkmene Nov 10 '10 at 20:43

1 Answers1

88

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

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • my tests suggest erkmene, above, is actually right - the browser sets the timeout... – hwjp Sep 05 '12 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: https://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](https://github.com/jquery/jquery/blob/master/src/ajax.js#L277). The default **for jQuery** (what the question was asking) is still effectively 0. – Nick Craver Sep 05 '12 at 11:57
  • 11
    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... – hwjp Sep 05 '12 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. – Kurt Dec 29 '14 at 09:42