Why don't synchronous ajax calls in jquery support timeout?

前端 未结 3 1130
被撕碎了的回忆
被撕碎了的回忆 2021-01-06 06:21

I was reading here that synchronous ajax calls in jquery don\'t time out.

Is this a technical limitation, or just something the authors didn\'t feel like supporting

3条回答
  •  梦毁少年i
    2021-01-06 06:30

    The browser handles synchronous/asynchronous requests via the XMLHttpRequest API, but it does not have a built-in timeout feature. JQuery implements its own timeout in JavaScript on top of the browser XHR API.

    Since a synchronous call blocks all running scripts, the JQuery timeout does not work. In theory, it seems like synchronous timeouts would be possible if they were implemented at the browser level, as opposed to the JS level.

提交回复
热议问题