设置 jQuery 的 get 速记超时

发布于 2024-09-08 14:38:09 字数 211 浏览 1 评论 0原文

是否可以使用 jQuery 的 get 简写来设置 ajax 超时参数?如果不是,使用速记发送的请求是否会超时?

jQuery.get(
    url, 
    [ data ], 
    [ callback(data, textStatus, XMLHttpRequest) ], 
    [ dataType ] 
)

谢谢。

Is it possible to set the ajax timeout parameter using jQuery's get shorthand? If not, do requests sent with the shorthand ever timeout?

jQuery.get(
    url, 
    [ data ], 
    [ callback(data, textStatus, XMLHttpRequest) ], 
    [ dataType ] 
)

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

上课铃就是安魂曲 2024-09-15 14:38:09

是否可以使用 jQuery 的 get 简写来设置 ajax 超时参数?

不,不是每个请求,尽管您可以使用 $.ajaxSetup( )所有请求执行此操作。

如果没有,使用简写发送的请求是否会超时?

不,默认情况下它们不会(除非您使用 $.ajaxSetup({ timeout: value } );),默认超时 选项 未定义,与0 表示“不超时”。


要对每个请求进行超时而不是全局超时,您必须切换到普通格式:

$.ajax({
  url: url,
  data: data,
  success: callback(data, textStatus, XMLHttpRequest),
  dataType: dataType,
  timeout: timeoutvalue
});

Is it possible to set the ajax timeout parameter using jQuery's get shorthand?

No, not per request, though you can use $.ajaxSetup() to do it for all requests.

If not, do requests sent with the shorthand ever timeout?

No, by default they won't (unless you used $.ajaxSetup({ timeout: value });), the default timeout option isn't defined, the same as 0 meaning "don't timeout".


To do a timeout per request and not globally, you'd have to switch to the longhand format:

$.ajax({
  url: url,
  data: data,
  success: callback(data, textStatus, XMLHttpRequest),
  dataType: dataType,
  timeout: timeoutvalue
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文