关于ajax的timeout问题

使用ajax提交数据的时候,由于网络问题很久都没提交完毕,此时如果设置timeout的值,例如5秒,那么这个值是timeout==前端提交时间? 还是 timeout==前端提交时间+后端响应时间?当timeout值达到的时候是否已经触碰到服务器呢?
希望有大神能相信解答一下

阅读 2.8k
2 个回答

你指的网络问题是?你浏览器访问后端接口 看能访问到不

是 jQuery 的 ajax ? jQuery.ajax

The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period.

从调用 $.ajax 开始计算,不管是否触碰到服务器,只要到时间就 time out。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题