Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery ajax call default timeout value

I got a bug report that I can't duplicate, but ajax-call timeout is the current best guess.

So I'm trying to find out the default value for timeout of a jQuery $.ajax() call. Anybody have an idea? Couldn't find it in jQuery documentation.

Thanks in advance, Marcus

like image 661
Marcus Avatar asked Mar 24 '10 11:03

Marcus


People also ask

What is the default jQuery Ajax timeout?

The default value is 0. Which means there is no timeout. The ajax timeout option does not return any value. The jQuery ajax timeout option is passed to the ajax() function with the value to specify the timeout for the request to the server.

What is the default browser timeout?

The GUI Inactivity Timeout defaults to 900 seconds (15 minutes). If a user's browser session is not active for this amount of time, the session times out. As required, you can increase or decrease the timeout period by setting the GUI Inactivity Timeout display option.

What is ajaxSetup?

The ajaxSetup() method in jQuery is used to set the default values for future AJAX requests. Syntax: $.ajaxSetup( {name:value, name:value, ... } ) Parameters: type: It is used to specify the type of request.


2 Answers

There doesn't seem to be a standardized default value. I have the feeling the default is 0, and the timeout event left totally dependent on browser and network settings.

For IE, there is a timeout property for XMLHTTPRequests here. It defaults to null, and it says the network stack is likely to be the first to time out (which will not generate an ontimeout event by the way).

like image 160
Pekka Avatar answered Sep 18 '22 16:09

Pekka


As an aside, when trying to diagnose a similar bug I realised that jquery's ajax error callback returns a status of "timeout" if it failed due to a timeout.

Here's an example:

$.ajax({     url: "/ajax_json_echo/",     timeout: 500,     error: function(jqXHR, textStatus, errorThrown) {         alert(textStatus); // this will be "timeout"     } }); 

Here it is on jsfiddle.

like image 31
Jonathan Moffatt Avatar answered Sep 18 '22 16:09

Jonathan Moffatt