【问题标题】:ajax server call getting timeout even after adding timeout即使在添加超时后,ajax 服务器调用也会超时
【发布时间】:2019-10-21 22:02:13
【问题描述】:

我有一个服务器 ajax 调用,即使服务器响应也返回超时。

如果服务器在 2-4 分钟内回复,则 ajax 成功 如果服务器在 4 分钟后响应,则 ajax 调用中没有发生任何操作

我也尝试过在 ajax 调用中设置超时,但没有成功。

甚至在配置中添加了 http 超时。

$.ajax({
        url: urlAction,
        type: "POST",
        async: true,
        data: {
            data : "parmeters"            
        },
        success: function (data) {

        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            // after 15 mins this is throwing timeout error
        },
        timeout: 900000
        });

    }

但我可以看到服务器方法正在返回正确的 json。

【问题讨论】:

  • 你能告诉我们你的尝试吗?
  • 添加一些代码,看看我们能提供什么帮助
  • @wasanga7 我已经更新了 ajax 请求。
  • @madalinivascu 更新 ajax 请求

标签: javascript jquery ajax timeout


【解决方案1】:

你可以在超时后中止 xhr

 error: function (XMLHttpRequest, textStatus, errorThrown) {
   XMLHttpRequest.abort();
 },

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-05
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    相关资源
    最近更新 更多