1

can ajax request set timeout more than 2min? When I set timeout value more than 2min, It has not effect. I test in chrome and edge, when request time more than 2min it will return timeout.

Here is the code

$.ajax({
    type: "get",
    url: requestURL || jsonServer(),
    dataType: "text",
    data: requestdata,
    timeout: 240000,
    success: successCallback,
    async: syncFlag,
    cache: false,
    error: errorCallBack || function (data) {
    requestErrorCallBack(data);
}});
  • https://stackoverflow.com/questions/3543683/determine-if-ajax-error-is-a-timeout – tibetty Aug 17 '17 at 04:37
  • Please also make sure that the server that the ajax is requesting has a timeout value according to your ajax timeout, otherwise, no matter if the ajax request has a timeout value, in that case the server will throw a timeout error before the ajax timeout that you set. – Daniel C. Aug 17 '17 at 04:44
  • I add set_time_limit(0); same result. – user3436628 Aug 17 '17 at 06:22
  • The error callback text="error", the console output net::ERR_EMPTY_RESPONSE – user3436628 Aug 17 '17 at 06:28

1 Answers1

0

I got the same issue as well today. After few hours search, I found no any solution and explanations online. However, I kind of "solved" my problem luckily.

In my situation, I use webpack dev server to develop a SPA of Vuejs. The timeout issue actually fired by the dev server proxy. There is not any configuration for timeout in their doc. However, if you build your app and directly load your app without any dev server proxy, your code should be fine.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Felix
  • 33
  • 4