【问题标题】:Is there any maximum/minimum timeout for the xmlhttprequest?xmlhttprequest 是否有任何最大/最小超时?
【发布时间】:2017-03-15 09:09:27
【问题描述】:

xmlhttprequest 是否有任何最大超时?目前无法在 chrome 中设置超过 1 分钟的超时值。 让 xmlHttpRequest: XMLHttpRequest = new XMLHttpRequest(); xmlHttpRequest.timeout = 120000;

【问题讨论】:

  • 如果你这样做会发生什么

标签: javascript ajax google-chrome xmlhttprequest


【解决方案1】:

是的,在 chrome 中xmlhttprequest 有一个最大超时时间,即 1 分钟。不幸的是,您不能通过在 chrome 中设置 xmlhttprequesttimeout 属性来增加超时。但是如果你在windows上,你可能会在regedit的帮助下设置maixmum tmeout,步骤是……

  • window + r > 输入regedit > 按enter
  • 导航到HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings
  • 创建一个名为KeepAliveTimeoutDWORD 值并设置数据值120000(2 分钟)
  • 按照相同的步骤创建另一个名为 ServerInfoTimeout 的值
  • 重启电脑

【讨论】:

  • 感谢您的回答,我们可以使用javascript从客户端本身修改超时值吗?
【解决方案2】:

不,XMLHttpRequest 对象没有最大超时值,因为默认超时值为 0,表示无限。

来源:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout

您提到了 Chrome:您所在的网络堆栈确实有超时限制。

Google Chrome 不允许您更改默认超时值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-31
    • 1970-01-01
    相关资源
    最近更新 更多