Answer the question
In order to leave comments, you need to log in
How to change the timeout for the jQuery.ajax() function?
Hello, there was a need to reduce the timeout of an AJAX request to 2 - 3 seconds. If the server takes a long time to respond, jQuery.ajax() executes the function specified in error . How could I manually set the allowed response time? Does jQuery allow you to set such parameters out of the box?
Answer the question
In order to leave comments, you need to log in
I found a solution, the timeout parameter inside the JSON, which is passed to the function,
is responsible for the request timeout. More details below:
Time to wait for a response from the server. Specified in milliseconds. If this time is exceeded, the request will be terminated with an error and an error event (see description above) will be fired, which will have the "timeout" status.
The time is counted from the moment the $.ajax function was called. It may happen that several other requests will be fired at this point and the browser will defer the execution of the current request. In this case, the timeout may complete even though in fact the request has not even started yet.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question