Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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? What actually happens under the table when an ajax call is synchronous?

like image 958
pepsi Avatar asked Dec 22 '22 07:12

pepsi


1 Answers

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.

like image 164
pepsi Avatar answered Jan 14 '23 13:01

pepsi